© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu

C and C++ Interview Questions

2. What is Difference Between C/C++?

Ans:

C does not have a class/object concept.
C++ provides data abstraction, data encapsulation, Inheritance and Polymorphism.
C++ supports all C syntax.
In C passing value to a function is "Call by Value" whereas in C++ its "Call by Reference"
File extension is .c in C while .cpp in C++.(C++ compiler compiles the files with .c extension but C compiler can not!)
In C structures can not have contain functions declarations. In C++ structures are like classes, so declaring functions is legal and allowed.
C++ can have inline/virtual functions for the classes.
c++ is C with Classes hence C++ while in c the closest u can get to an User defined data type is struct and union

Ex Q1: Why do C++ compilers need name mangling?

Ans:

Name mangling is the rule according to which C++ changes function's name into function signature before passing that function to a linker. This is how the linker differentiates between different functions with the same name.

Ex Q2: Is it possible to have Virtual Constructor? If yes, how? If not, Why not possible ?

Ans:
There is nothing like Virtual Constructor. The Constructor cant be virtual as the constructor is a code which is responsible for creating a instance of a class and it cant be delegated to any other object by virtual keyword means.

Ex Q3: What about Virtual Destructor?

Ans:
Yes there is a Virtual Destructor. A destructor can be virtual as it is possible as at runtime depending on the type of object baller is balling to , proper destructor will be called.

Ex Q4: What are the conditions that have to be met for a condition to be an invariant of the class?

Ans:

Ø  The condition should hold at the end of every constructor.
Ø  The condition should hold at the end of every mutator(non-const) operation.

SLogix Student Projects
bottom