0

so I'm a C++ beginner and I have a question.

Let's say we have a class Grades.

From what I've learned so far a destructor would look like

~Grades();

a copy constructor:

Grades(const Grades & );

an << operator:

ostream & operator << (ostream & os, const Grades & g);

Are these correct?

How would a regular constructor look like? What about a conversion constructor ?

stacknoob
  • 49
  • 7
  • Hello, welcome to SO and nice that you took up C++ programming. One thing though, answers to questions like these [are](http://www.tutorialspoint.com/cplusplus/cpp_constructor_destructor.htm) [not](http://www.cplusplus.com/doc/tutorial/classes/) [hard](https://isocpp.org/wiki/faq/ctors) to find on Google [or](http://stackoverflow.com/a/15077788/3492835) [on](http://stackoverflow.com/q/10905866/3492835) [SO](http://stackoverflow.com/help/how-to-ask). – Sander Toonen Dec 11 '15 at 09:24

1 Answers1

0

Regular default constructor, provided by compiler, will look like below and it will internally call the base class constructors if it is derived from any class. And later for data members having user defined type, it will call their respective default constructors in the order of their declaration.

Grades();

The conversion constructors are something you will have to define, and they will look like

Grade(const T&)

If you want conversion function,

 Grade operator=(const T&)

The only destructor you could have is suppose to de-initialize the object by calling respective destructors if user defined data members and then for base classes, exactly in reverse order what default compiler provided constructor would provide.

rahul.deshmukhpatil
  • 977
  • 1
  • 16
  • 31