Simple GUI Notepad Using Ruby

GUI Notepad Using Ruby Code require 'tk' class Notepad def saveFile file = File.open("note", "w") ...

Thursday, January 29, 2015

Constructors

Constructor

In class based object oriented programming constructor is a special member function (or an subroutine) that is called to create object of a particular class. It prepares the object for use.

Properties

> A constructor will have same name as the class (exceptions: python, php, ruby ...)
> It does not have any explicit return type at all not even void. (as they always return the object of the existing class.).
> The constructor is called each time the object declaration is encountered.
> Like other functions constructor also have parameter list, and a (possibly empty) body.
> A class can have multiple constructor.
>Unlike other member function constructor must not declare as const.

Constructors Types
Constructor Types

Default Constructor

Default constructor (or synthesized default constructor) is a constructor generated automatically by the C++ compiler in the absence of any programmers defined constructor. A use defined no argument constructor is also called default. A parametrized constructor with all its arguments as default arguments is also called a default constructor.