C++ Programming - Objects and Classes - Discussion

Discussion Forum : Objects and Classes - General Questions (Q.No. 1)
1.
What happens when we try to compile the class definition in following code snippet?
class Birds {};
class Peacock : protected Birds {};
It will not compile because class body of Birds is not defined.
It will not compile because class body of Peacock is not defined.
It will not compile because a class cannot be protectedly inherited from other class.
It will compile succesfully.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
30 comments Page 2 of 3.

Arjun said:   1 decade ago
It is under the other defined class.

Nara said:   1 decade ago
It will compile successfully. A class can have no members.

Irshad said:   1 decade ago
Will it run successfully without declared main method ?

Naveen said:   9 years ago
There is no output but it compiled sucessfully.

Xxx said:   9 years ago
Agree with you @Akshay. So confused to choose the answer.

Pankaj sharma said:   1 decade ago
It will compile successfully but will not execute as main is the very first function to be called and it is called every time by say a master program running somewhere behind and from there the further references are given by us to do whatever required acc to need.

So it will only compile not execute.

PRABAVATHY said:   10 years ago
Ya it will inherited when we inherit using public and protected.

Sann said:   10 years ago
What situation we should inherit protected or private if class is public?

Nirbhay singh said:   10 years ago
This program is correct but no output. Because no constructor and destructor are use.

Suman said:   1 decade ago
The code will compile properly. Since the existence of class is only by object of that particular class and there are know syntax error in the code.


Post your comments here:

Your comments will be displayed after verification.