I have written some basic explanations, but perhaps you would be better off reading the tutorials on this site, starting with this one:
http://cplusplus.com/doc/tutorial/classes/
The first two are constructors:
1 2 3 4 5 6
|
class MyClass {
public:
MyClass();
MyClass(const MyClass&);
// ...
};
|
These are
constructors. They are called when an object of the class is created.
The first is a default constructor, with no arguments. This constructor is provided by default if no custom constructors are provided. The second is a copy constructor to define how one object of this type is copied to another. This, too, is usually provided by default.
The
throw()
means that the function does not throw any exception.
On the other hand,
throw(some_type)
means that the function would only throw an exception of type
some_type. However, Visual C++ 2010 ignores the second one.
The third line
exception& operator= (const exception&) throw();
Is an assignment operator. It is a function to define how one object of this type is assigned to another of this type, using the assignment operator '='. It accepts a reference parameter of the same type as the class, which is the object on the other side of the equals sign. It returns a reference, which is the object assigned to.
For example:
1 2
|
exception a();
exception b = a;
|
The second line calls
operator=
with a reference to
a
as the argument. It returns the value of
b
after assignment.
Next is the destructor, ~exception. In general, these have the form ~
class_name(). Note the lack of an argument list. This object is called when the lifetime of an object of this type ends. The virtual keyword is so that in
derived classes, an override function with the same prototype in the derived class is called not the base one.
Virtual means the same in the last line. It is a member function called what which accepts no arguments, will not throw an exception and returns a pointer to a constant character array.
Hope this helps. See the tutorials on this site for details.