It depends on the classes. If you're in a classA function, it will return classA's name. If you're in a classB function, it will return classB's name.
Although if you are inheriting, only the parent class should have a name. The derived class should not have a separate name. That way both classA and classB share the same name.
class B {
public:
std::string name;
};
class A : public B {
public:
std::int age;
}
1 2 3 4 5 6 7 8
A a;
B b;
a.name = "Acr"; //Class B has a name field, Class A inherits from B, so Class A also has a name field.
a.age = 12;
b.name = "Disch";
b.age = 1; // <---- Not possible!