class Foo {
public:
Foo(int i) { }
};
class Bar : virtual Foo {
public:
Bar() { }
};

Bar b;

Referring to the above code, when the object 'b' is defined,
a compiler error will occur. What action fixes the compiler
error?
a) Adding a virtual destructor to the class Bar
b) Adding a constructor to Bar which takes an int parameter
c) Adding "Foo()" to the Bar constructor
d) Adding a copy constructor to the class Foo
e) Adding "Foo(0)" to the Bar::Bar initializer list

Answers were Sorted based on User's Feedback



class Foo { public: Foo(int i) { } }; class Bar : virtual Foo { public: Bar() { }..

Answer / man

class Foo {
public:
Foo(int i) { }
};
class Bar : virtual Foo {
public:
Bar():Foo(0) { }
};

Ans e

Is This Answer Correct ?    7 Yes 0 No

class Foo { public: Foo(int i) { } }; class Bar : virtual Foo { public: Bar() { }..

Answer / guest

Ans. E

Is This Answer Correct ?    6 Yes 0 No

Post New Answer

More C++ General Interview Questions

why is c++ called oops? Explain

0 Answers  


What is a type library?

0 Answers  


What are vtable and vptr?

0 Answers  


What is stl containers in c++?

0 Answers  


Write a Program for dynamically intialize a 2 dimentional array. Eg:5x20, accept strings and check for vowels and display the no.finally free the space allocated .

0 Answers  






Why struct is used in c++?

0 Answers  


Who was the creator of c++?

0 Answers  


Difference between declaration and definition of a variable.

0 Answers  


Please explain the reference variable in c++?

0 Answers  


What is doubly linked list in c++?

0 Answers  


Can I have a reference as a data member of a class? If yes, then how do I initialise it?

0 Answers  


What is the difference between the functions rand(), random(), srand() and randomize()?

0 Answers  


Categories