Whats wrong with the following code, its not compiling
Posted
by
Ganesh Kundapur
on Stack Overflow
See other posts from Stack Overflow
or by Ganesh Kundapur
Published on 2011-03-17T08:01:54Z
Indexed on
2011/03/17
8:09 UTC
Read the original article
Hit count: 207
c++
#include <iostream>
#include <vector>
using namespace std;
class Base
{
public:
void Display( void )
{
cout<<"Base display"<<endl;
}
int Display( int a )
{
cout<<"Base int display"<<endl;
return 0;
}
};
class Derived : public Base
{
public:
void Display( void )
{
cout<<"Derived display"<<endl;
}
};
void main()
{
Derived obj;
obj.Display();
obj.Display( 10 );
}
$test1.cpp: In function ‘int main()’:
test1.cpp:35: error: no matching function for call to ‘Derived::Display(int)’
test1.cpp:24: note: candidates are: void Derived::Display()
On commenting obj.Display(10), it works.
© Stack Overflow or respective owner