Constructors in C++

racinggamesios kidsgamesios windows appcolt
 31 December 18:00   


What is a Constructor?


A architect is a appropriate adjustment that is created if the item is created


or defined. This accurate adjustment holds the aforementioned name as that of the item


and it initializes the instance of the item whenever that item is created.


The architect aswell usually holds the initializations of the altered declared


affiliate variables of its object. Clashing some of the additional methods, the architect


does not acknowledgment a value, not even void.


When you make an object, if you do not acknowledge a constructor, the compiler would make one for your program; this is advantageous because it lets all additional altar and functions of the program understand that this item exists. This compiler created architect is alleged the absence constructor. If you wish to acknowledge your own constructor, artlessly add a adjustment with the aforementioned name as the item in the accessible area of the object. If you acknowledge an instance of an object, whether you use that item or not, a architect for the item is created and signals itself.


A architect is declared after a acknowledgment value, that aswell excludes void.


Therefore, if implemented, do not acknowledgment a value:


Constructor Example


class rectangle {              // A simple class


int height;


int width;




rectangle(void); // with a constuctor,


~rectangle(void); // and a destructor




rectangle::rectangle(void) // constuctor




acme = 6;


amplitude = 6;






Discuss this tutorial here



Forum: Constructors (Total 2 Messages)


Tags: created, value, method

 object, constructor, created, rectangle, declare, value, constructors, method, return, ,

Share Constructors in C++: Digg it!   Google Bookmarks   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

Article In : Computers & Technology  -  C Plus Plus Programming Tutorials