#pragma once
class Base
{
public:
const char* method() const
return "I am an instance of class Base";
}
};
class Derived : public Base
return "I am an instance of class Derived";
What would the following code output?
Base b;
std::cout << b.method() << std::endl;
I am an instance of class Base
Derived d;
std::cout << d.method() << std::endl;
I am an instance of class Derived
Base* b = &d;
std::cout << b->method() << std::endl;
virtual const char* method() const
Last changed2 years ago