Search This Blog

Monday, October 26, 2009

About Constructor

A constructor is a function that initilizes the members of an object. A constructor only knows how to build an object of its own class.
Constructors aren't automatically inherited between base and derived classes. If you don't supply one in the derived class, a default will be provided but this may not do what you want.

If no constructor is supplied then a default one is created by the compiler without any parameters. There must always be a constructor, even if it is the default and empty. If you supply a constructor with parameters then a default will NOT be created.

Some points about constructors

Constructors are just functions with the same name as the class.
Constructors are intended to initialize the members of the class when an instance of that class is created.
Constructors are not called directly (except through initializer lists)
Constructors are never virtual.
Multiple constructors for the same class can be defined. They must have different parameters to distinguish them.

3 comments :

  1. can you please tell me what's the concept of virtula in constructotrs i mean these are virtaual functions or what..please try to reply..

    ReplyDelete
  2. Basically received my first cavity. Rather devastating. I would like a super smile. Looking a lot more choices. Many thanks for the article click for source

    ReplyDelete
  3. titanium tube vs aluminum tube? - Baojititanium
    How 스포츠 토토 사이트 are aluminum oxide 바카라 oxide baoji titanium vs aluminum tube vs aluminum tube? I've recently used these and also discovered what I 1xbet 먹튀 called "TIN" which I like 바카라 사이트 유니 88

    ReplyDelete