Wednesday, 11 September 2013

How to make this work?

How to make this work?

I'm pretty sure I know why this isn't working but how do I make this work?
Ok so I have a parent class that has a bunch of virtual functions and 1
non virtual function
Ex:
class Parent
{
private:
int variable;
public:
virtual void firstfunction();
virtual void secondfunction();
void nonvirtualfunction();
};
Parent::nonvirtualfunction()
{
variable = 5;
}
I have a child class that inherits from the parent class
class Child : public Parent
{
void firstfunction();
void secondfunction();
}
Child::secondfunction()
{
Parent::nonvirtualfunction();
}
When I call nonvirtualfunction inside my child class it doesn't change the
value inside the parent class. How do I make it so that I can change the
parent class' variables inside the child class?

No comments:

Post a Comment