Question for C++
Posted on 2004-04-22
Hi, can someone help me with these 5 questions. I could not find the answers. The questions are multiple-choice.
1. Which statement is true about classes?
A) The class declaration should be contained in a .cpp file.
B) An error will occur if the function is written within the class declaration.
C) The class function definitions (source code) should be placed in the .cpp file.
D) Class declarations and definitions (source code) should be placed in the .cpp file.
2. An overloaded operator member class member function is convenient for:
A) Comparing two objects of the same class
B) Initializing variables in an object
C) Ensuring that data hiding has been performed
D) Adding two objects that are not related
3. If class A contains an overloaded binary operator function, what is not true?
A) The operator function must have a data type A as an input.
B) The operator function must have a return data type.
C) The operator function will have a void return type.
D) All of these statements are true.
4. The use of classes is an example of which principle of object oriented language?
5. Where are class variables initialized?
A) Only in a function
B) Only in a constructor
C) In a function or a constructor
D) In the variable declaration