-
Question of test c++
is somebody now, which answer is ok. ?
thank yuo for help :)
Which of the following special methods can be created implicitly by C++ compiler inside a class (let’s say A)?
a. the operator: const A& operator()(const A&);
b. the operator: void operator~(const A*);
c. the assignment operator: A& operator=(const A&);
d. the constructor: A(const A*);
-
i wish i could tell that they are a and c
but that would be wrongo :D
tell us your guess?
-
Sorry, you can't offload your exams on us.
-
CornedBee, do you valid answer??
It's not may exam. I want to know it.
I have problem with this question.
best regarts,
endrzer
-
You could explain what you think and why. We can help to correct your understanding if it's incorrect.
-
i think it's
c) the assignment operator: A& operator=(const A&);
but i'm not sure..
-
Yes, that is correct.
Code:
class A { };
void Help()
{
A a, b, c;
a = b = c;
}
This code obviously works but wouldn't if the compiler didn't automatically generate that operator by default.
-
Thank you very much Elysia:)
best regarts,
endrzer
-
Next time you might try writing a small test program. Write a class that doesn't overload any of these operators and see which ones the compiler lets you call.