Classification of these C++ declarations in my homework assignment
Suppose that MyClass has methods with the following prototypes:
void method1(MyClass & object1);
MyClass * method 7();
What will this method be, a destructor, constructor, copy constructor, overloaded= or default constructor?
Th开发者_StackOverflowis is one of the questions in my homework.
I think the first one is the default constructor and the second one is a copy constructor, but I am not sure about it. I know that these methods are not destructors for sure, so I need help with this.
Neither of those methods will be any of the options in the question. The question is really asking "How do all these things (destructor, constructor, etc.) get into the class?" All C++ classes will have them. Where do they come from, and what will they look like?
You can find examples and information about each of those methods by searching Google for phrases like "C++ constructor" or "C++ copy constructor." That should lead you to plenty of educational resources that will help you be able to answer your question.
See the section on "Constructors and Destructors".
精彩评论