What will be printed as a result of executing the following program?
#include <iostream>

class Base
{
public:
	virtual void Foo() { std::cout << "Base::Foo "; }
	virtual ~Base(){}
};

class Derived: public Base
{
public:
	void Foo(int k = 0) { std::cout << "Derived::Foo "; }
};

int main()
{
	Base *d = new Derived;
	d->Foo();
	delete d;
	return 0;
}
Explanation
Since there is no function Derived in the class Derived without arguments that would replace the virtual function of the class Base, the function Base::Foo() will be called.

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести