0

So, I'm a bit confused with how inheritance works in relation to variables. Let's say that I had the following class:

class Test
{
private:
int var1;
float var2;

public:
void getInfo(int,float);
void setStuff(int,float);
};

Now, let's suppose that I wanted to derive a class from that base class; I want the derived class to be able to access member functions from the base class to modify its own private variables, but not overwrite the variables of the base class. How would I define the derived class?

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Ancient Dragon
0

The derived class just calls the base classes public member functions, they can not change the value of private member data objects or call private functions.

Edited by Ancient Dragon: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.