I am trying to create an instance of class inside class. I have declared two classes = first
class Student{
public:
Student(string m,int g){
name=m;
age=g;
}
string getName(){
return name;
}
int getAge(){
return age;
}
private:
string name;
int age;
};
And second , where i want to create instance of student.
class Class{
public:
Class(string n){
name = n;
};
string studentName(){
return Martin.getName();
}
private:
string name;
Student Martin("Martin",10);
Student Roxy("Roxy",15);
};
I keep getting this errors
'((Class*)this)->Class::Martin' does not have class type
expected identifier before string constant|
The Student was defned before Class so it shouldnt have problem to access it. What causes this behavior? How can i fix it?