Answer the question
In order to leave comments, you need to log in
How to call a child function with the same name as the parent (C++)?
I recently started learning OOP. But here's something that can't be sorted out. Here is an example program code. How to make it so that the function of the child is called in the main, and not the parent?
class tparent
{
...
public:
...
void getdata()
{
...
}
};
class tchild:public tparent
{
...
public:
void getdata()
{
...
}
};
void main()
{
tchild ob;
ob.getdata();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question