in Object Oriented Programming recategorized by
2,708 views
2 votes
2 votes

Assume that we have constructor functions for both base class and derived class. Now consider the declaration in

main()

Base *P=New Derived;

In what sequence will the constructor be called?

  1. Derived class constructor followed by Base class constructor
  2. Base class constructor followed by Derived class constructor
  3. Base class constructor will not be called
  4. Derived class constructor will not be called
in Object Oriented Programming recategorized by
2.7k views

1 Answer

2 votes
2 votes

ans is  B
Here A derived class object is created first and then assigned to a base class pointer. Whenever a derived class object is created, the base class constructor gets called first and then the derived class constructor.
 

Answer:

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true