What will be printed out as a result of the following code execution?
#include <iostream>
using namespace std;

class C
{
public:
    void Print() { cout << "CLASS C"; }
};

class D : public C
{
public:
    void Print() { cout << "CLASS D"; }
};

int main()
{
    C *test = new D();
    test->Print();
}
Explanation
SInce virtual modifier is missing, an early binding will be used, and function by the pointer type will be called.

@tradingstata05 thanks! updated

2017 Dec 5, 3:30:57 PM

using namespace std;

2017 Nov 28, 7:19:00 PM

#include <iostream>

2017 Nov 28, 7:18:35 PM

Please add:

2017 Nov 28, 7:17:29 PM

Please add:

2017 Nov 28, 7:16:23 PM

Слідкуй за CodeGalaxy

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

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