Proper variable declaration using ADTs??

I would like to know the proper way of declaring variables that are relative to a class (file) using ADTs. I'm working on a small project which involves a good amount of variables, most of which relate directly to one of my header & implementation files.

Here is an example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
class numbers {
public:
      // functions, constants, etc ...
private:
     int num1;
     int num2;
     int num3;
     struct propertyType {
            double Avg;
            double mean;
            char rating;
     } property;
     int instance[100];
};


When working with ADTs, should I be declaring all of those variables within the private of the class, or should those variables be declared throughout, or initially, in the implementation file??

Also, might anyone know of a good read for the do's and dont's when working with ADTs AND classes?

All help is greatly appreciated. Thank you.
No ideas?
It is not clear what you are saying about. What variables are you speaking about? I see only a class definition and its data members. You already declared them as private. It is a good idea to hide the realization inside the class and provide an open interface as public methods.
Thank you vlad. I think you may have stated my query a little better. Although, I'm not exactly concerned with if the variables (members) should be public or private. It's more an issue of whether or not they should be declared within the class at all, or declared within the .cpp implementation file.

Implementation file:

1
2
3
4
5
6
7
8
9
10
#include "numbers.h"

using namespace std;

// Declare variables here?

void numbers::someFunction()
{
  // And/or declare variables here?
}


Technically I guess both could work? But I think there would have to be a lot of data copying to do if all or most variables were declared at random. I'm getting concerned with the project I am working on because I'm starting to notice that I'm declaring quite a lot of private members. Also, I've noticed that none of the many member functions I have pass any parameters. There issues are having me wonder if I'm doing things correctly.

I appreciate the help.
> a good read for the do's and dont's when working with ADTs AND classes?

'Ruminations on C++' by Koenig has a chapter called 'Checklist for Class Authors.'
The list of issues covered are reproduced here:
http://lkmsoftware.wordpress.com/2007/01/11/checklist-for-c-class-authors/


> It's more an issue of whether or not they should be declared within the class at all

Yes. Variables that together define the state of an object of that type.

Topic archived. No new replies allowed.