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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok, cool. thanks
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.