Question 15: Predict the output.
class DemoClass
{
public:
void display()
{
std::cout<<"\nDisplay Function 1";
}
void display() const
{
std::cout<<"\nDisplay Function 2";
}
};
int main()
{
DemoClass obj;
obj.display();
}
Options:
(a) Display Function 1
(b) Runtime Error
(c) Compile Time error: error C2535: 'void DemoClass::display(void)' : member function already defined or declared.
(d) None of the above.
Answer: a
this happens because the object created here is non const .
ReplyDeleteCheck this out for more details :
http://www.geeksforgeeks.org/archives/24724