• #### C Pointer Size

If p is declared as char *p then what is size of(*P)?

#### vaishali

• Feb 28th, 2012

Size of *p is 1 byte, as it is character pointer.

#### Divya

• Jan 10th, 2012

Array[0]

• #### C/C++ black screen opens and closes

While executing a program in C++, it happens the black screen opens and closes automatically without displaying the output(program is correct). How to recover from this situation?

#### Amit

• Jun 27th, 2014

Use getchar() before return in the main.

#### sebius

• Aug 25th, 2013

Try this

`Codesystem("pause");`

• #### Divide and find reminders

find a number that divide 37,67,97 reminders will be 1,2,3 respectively.

#### VINOTH

• Dec 14th, 2011

The dividend are 6,5,2... the quotient is 6,13,47... the reminder is 1,2,3...

#### surendrap

• Oct 4th, 2011

There is no such number except 1.......

• #### C++ without Header files

How we can run our c++ program without header files?

#### Eric Nantel

• Apr 23rd, 2015

Put everything in the only cpp containing main()

#### harshit

• Apr 14th, 2015

We can run c++ program without using header files by making the definition of all the functions and keywords in the programs

• #### Three random Numbers question

Three numbers are selected at random without replacement from n number,what is the probability that the first number drawn will be the smallest and the second is the largest

• Dec 11th, 2011

1C1*1C(N-1)*1C(N-2)/3C(N-3)

#### surendrap

• Sep 26th, 2011

(1C1.1C1.1C(n-2)) / (3C(n-3)

• #### Inheritance in C++

While doing inheritance in C++, one thing that is not inherited is what?

#### rohit suri

• Sep 11th, 2014

There are four things which r not inherited in c++
1>Constructor
2>Destructor
3>Assignment operator
4>copy constructor
5>Friend function

#### Johnny

• Jan 6th, 2014

Friend declarations.

#### surendrap

• Oct 4th, 2011

Simple class is template.no memory is allocated to class until object is declared of that class.

#### kaviraj

• Sep 30th, 2011

Class is a collection of objects shared a common name ,an object is a runtime entity of a class,using the object we can access class members and functions easily.

• #### Dead Code

What is dead code? Explain in programmatic way?

#### mfsi_chinmayb

• Feb 20th, 2012

Hi Dead code (a.k.a Unreachable code),as the name suggests is the portion of the code which is never executed. Point out the word NEVER , as the code above that made the break before that and the exec...

#### surendrap

• Nov 21st, 2011

Dead code is such a collection of lines of code or code which executes but it its result does not have any significance or affect on output.

### Editorial / Best Answer

chethanhb

• Member Since Feb-2010 | Feb 25th, 2010

I am one of the person who has pricked my head in understanding the above question. Let me explain in my way...

If you have virtual function or (let me take just "virtual" keyword as of now), it means that this member function can be redefined by derived class. When we have a virtual function in a class, it will have vtable (virtual table). This vtable will have the address of the virtual function which is defined in derived.
Now the point is, how you invoke the virtual function which is defined in derived class with the help of object of the class?
Once you create an object of class, vptr (virtual pointer) will be created. Which inturn will be pointing to the base address of the vtable. So now it is clear that you can invoke the virtual funtion of derived class only with an object that has created.
Now coming to virtual constructor,
If we make constructor as virtual in base, it means that it could be redefined in derived. Keep in mind that constructor is invoked during object creation (object is not created yet. still it is in the status "creating". Object will create only after executing constructor part code). Assume you are trying to create object of the class which has virtual constructor. During this process constructor of the class will be invoked. It looks for virtual keyword. Now it tries to look for virtual constructor in derived. But not possible bcz there is no vptr and no vtable avaibale at this point of time. So, when object is not created, then there is no vptr. If no vptr for this object, then how the consturtor of derived is invoked?. No address of this construtor will available in vtable.
Hence there is no point in having virtual constructor.

I believe that i have cleared your doubt.

#### Venkataramakrishna

• Mar 22nd, 2018

Whenever a class object is created this pointer is created just before initializing class constructor member values. If the constructor is virtual, you cannot create this pointer.

#### vikash tiwary

• May 11th, 2017

Virtual functions are used in order to invoke functions based on the type of object pointed by the pointer. But is not "invoked", it is called only once when it is declared. so, a constructor cannot be virtual.

#### venky

• Jul 5th, 2016

Program is machine code combined with data as a executable image, which is passive. If program is actively in running then its called process.

#### Ashwini D M

• May 13th, 2016

The new process and the process representing execution of program have a many to one relationship with the program. This is called concurrent program. processes that coexist in the system at some time...

• #### What is abstraction?

Abstraction is of the process of hiding unwanted details from the user.

#### Ramya

• May 31st, 2013

Mechanism of exposing only the interface and hiding the implementation data from user.

#### mukrram ur rahman

• Dec 9th, 2012

Abstraction exactly involve the process of involving relevant things while ignoring the irrelevant things.

• #### If a method is declared as protected, where may the method be accessed

A protected method may only be accessed by classes or interfaces of the same package orby subclasses of the class in which it is declared.