Which of the following is correct syntax to declare C++ class B to be a public base class for derived class D
a. public base class B: class D {/*…*/};
b. class D : public class B {/* … */};
c. class D : public B {/* … */};
d. class B: public D { };
e. None of the above
c)
Explanation: Part a) is a corruption of the syntax. Part b) has an extra class keyword. Part d) has base and derived classes backwards.
You might also like to view...
Any type of RAM will work in your computer
Indicate whether the statement is true or false
Analyze the following code:
``` public class A extends B { } class B { public B(String s) { } }``` a. The program has a compile error because A does not have a default constructor. b. The program has a compile error because the default constructor of A invokes the default constructor of B, but B does not have a default constructor. c. The program would compile fine if you add the following constructor into A: A(String s) { } d. The program would compile fine if you add the following constructor into A: A(String s) { super(s); }