I am very much new to c++. I have a situation like: I have a base class which holds two virtual functions(NOT PURE). I have a derived class for this class where I implemented those virtual functions. Now in my main() function I created a pointer to pointer object to the base class. Now using this object how can I access the derived class object and functions.
I only want the pointer to pointer object of base class should be used to access derived class object.
BASE CLASS:
class another
{
public:
virtual void setName(){};
virtual string getName(){};
};
Derived Class
class use: public another
{
public:
string str;
void setName()
{
str = "USE CLASS";
}
string getName()
{
return str;
}
};
MY main() function:
int main()
{
another **an;
*an = new use();
an->setName(); //getting error
cout<<an->getName()<<endl; //getting error
return 0;
}