Networking, Programming and Graphics Tutorials

Constructor - C++ [1/1]

Type:
Constructor - C++
Level: Intermediate Networking, Programming and Graphics Tutorials Networking, Programming and Graphics Tutorials 
Constructor - C++
Date: 2006-Dec-08
Constructor - C++
Visited: 1528 times
Constructor - C++
Rating: Constructor - C++
Constructor - C++
Author: Alex Plumpton

Constructor function is a special function that is a member of a class and has the same name as that class. For example the figure above shows the stack class when converted to use a constructor function for initialization. You can notice that the constructor stackQ has no return type specified. In C++, constructor functions cannot return values and thus, have no return type.

Constructor - C++
Characteristics of constructer function

1. Should be declared in the public section.
2. Invoked automatically when the objects are created.
3. Do not have return types so cannot return any values.
4. Can have default arguments.
5. Cannot be virtual.
6. Cannot refer to their address.
7. Object with a constructor cannot be used as member of a union.
8. Makes implicit calls to the operator new and delete when memory allocation is required.
9. Cannot be inherited, through a derived class can call the base class constructor.

Rate this tutorial:                    
Networking, Programming and Graphics Tutorials - Constructor - C++ [1/1] - Networking, Programming and Graphics Tutorials

Need a specific tutorial? Do not hesitate and submit a request!
Related Tags: multiple constructor and copy constructor in c++  what is constructor-c++  WHAT IS A CONSTRUCTOR-C++  using constructor C++  constructor-c++  constructor  copy constructor c++  declaring a constructor c++  "c++ copy constructor"  ifstream constructor c++  c++ constructor stack  C++ multiple constructor  delete *this in constructor+C++  parameterized constructor in c++  copy constructor in C++  copy-constructor in c++  characteristics of constructor + c++  copy constructor in c++  parameterised constructor in c++  union constructor c++