Reputation: 27
There is a struct already defined in C++. I need to add more data members/variables as that class's object's attributes. Can it be done? If yes, then how?
Upvotes: 0
Views: 383
Reputation: 59
What you could do:
class
non_writable
{
int private_member;
int private_function (int, int);
protected:
char protected_member;
char protected_function (char, char);
public:
double public_member;
double public_function (double, double);
};
class
my_class : public non_writable
{
public:
double introduced_variable;
double introduced_function (double, double);
}
The downfall to this method is that private members (i.e. private_variable
, private_function
) will not be inherited to my_class
.
Upvotes: 1