0

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?

This 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.

Mat
  • 202,337
  • 40
  • 393
  • 406
cool
  • 89
  • 1
  • 2
  • 9
  • 1
    are you sure about `method 7`? – Anycorn Sep 21 '10 at 23:28
  • 2
    Neither of these is a constructor; they are both ordinary member functions (assuming they are declared in the body of the class and assuming the second one is intended to be named `method7`; otherwise it's just ill-formed). Why do you even think that they are constructors? You need to read your C++ book; if you don't have one, you should get [a good introductory book](http://stackoverflow.com/questions/388242/the-definitive-c++-book-guide-and-list). – James McNellis Sep 21 '10 at 23:30

3 Answers3

0

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?

Tim Yates
  • 5,151
  • 2
  • 29
  • 29
0

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.

0

See the section on "Constructors and Destructors".

dublev
  • 4,257
  • 4
  • 18
  • 12
  • 1
    Apparently today I got the answer from my professor and above two methods are nothing. It was trick. – cool Sep 24 '10 at 22:05