Link to home
Start Free TrialLog in
Avatar of highqllc
highqllc

asked on

can I declare a c++ constant object?

Hi,

What's the correct way to declare a c++ constant user-defined object?

For example, I declare other constants in a header file like:

static const int ERROR_CODE = 2;

I'd like to do the same, but with an aggregate object -- let's say Person.  Person may just have a few members like

private:
string name;
float weight;

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Infinity08
Infinity08
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> Hm, there's nothing special about the constructor for a const object

I meant that you need a constructor that takes a string and a float, and sets the class members properly. Not just a default constructor.
Avatar of highqllc
highqllc

ASKER

ok, cool.  thanks