inistializing derived class veriables
Sorry if my terminology is off, it's been a long while since i've practiced programming.
Code:
#include <iostream>
#include <string>
using namespace std;
class parent{
protected:
int age;
public:
//setter
void setValue(int age) { age=age; }
parent(int);
//getter
int getAge() { return age; }
//methods
void talk() { cout<<"I am the parent, shuttup a your face! "<<endl; }
};
class son:public parent{
private:
int number;
public:
};
parent::parent(int age){
this->age=age;
};
int main () {
parent dad(45);
}
i am trying to initialize the variable in the derived class son, i can't find a way and i have been mashing it out for a few hours now, can someone please tell me how, thanks in advance!