Saturday, September 1, 2007

C++ Quiz

Question 1
Can you name the special functions a C++ compiler can create implicitly?

Question 2
What are the two ways to achieve automatic type conversion from type X to type Y?

Question 3
Which of one of these represents an assignment operation?
1. C c1 = c2;
2. c3 = c4;
3. both


Answers


Answer to question 1
The four special functions that may be generated by the compiler are:
1. the default constructor
2. the copy constructor
3. the operator=() function
4. the destructor

Answer to question 2
X can define the member function operator Y()
Y can define the constructor Y(const X&)

Answer to question 3
c3 = c4 is an assignment
C c1 = c2 is a copy-construction



No comments: