I am using nested classes in a sensor library development and running into errors. Below is sample code and explanation.
MainClass.cpp
class MainClass
{
public:
class nested_class;
void func1(){
nested_class1.print();
}
};
NestedClass.cpp
class MainClass::nested_class
{
public:
virtual void print() = 0;
};
Nested1.cpp
class nested_class1: virtual public MainClass::nested_class{
public:
void print();
};
void nested_class1::print(){
cout<<"This is for 1\n";
}
Nested2.cpp
class nested_class2 : virtual public MainClass::nested_class{
public:
void print(){
cout<<"This is for 2";
}
};
I am trying to use it to extend the concept of abstraction in my sensor library. But on doing so following is the error: print() was not declared in this scope.
I am newbie to this concept and hence having a hard time finding the issue here. Where am I going wrong here? I can provide more details if required.
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire