Skip to main content

Constructors in c++

                                                    Constructors
In c++ provides a special member function called the constructor.which enable the object to inilaze when it is created.It is a special function its name is the same as class name.
The constructor function is invoked whenever an object of its associated class is created.It is called constructor because it construct the values of data members of the class.In constructor that accepts no parameter is called the default constructor.If no such constructor is define than the compiler supplies a default constructor.The constructor that accept parameters as a argument is called parameterized constructor.
Characterstatices :-
Ø     Constructors should be decleare in the public section.constructor are invoke automatically when the objects are created.They do not have return types, not even void therefore a constructor cannot return values.
Ø     Constructor can not be inherited,but a drived class can call the base class constructor.
Ø     Like c++ function a constructor can have default arguments.
Ø     Constructors cannot be virtural
Ø     It cannot refer the address of a contructor.
Ø     An object with a constructor or distructor cannot be news as a member of union.

Ø     A constructor make implicit calls to the operators new and delete.when memory allocation/deallocation is required.

Comments

Popular posts from this blog

Entrepreneurship Need and significances of entrepreneurship development It is said that an economic is an effect for which entrepreneurship is the cause. Entrepreneurship has development has therefore become a matter of great concretion in all countries. We can see the development of graph to America is developed day by day and become a most powerful country in the world due to development of entrepreneurship. almost all related entrepreneurship exists in America in different sector like industry, web developments, scientific research and so on. In other countries entrepreneurship development is a serious problem . all countries want to developed there entrepreneurship but the real problem is how to developed entrepreneurship. We have to create a program regrading entrepreneurship program(edp) offer the solution of this problem. Business main possess certain competitions which result in superior performances the question that arises is weather these characteristics are inb...

Pointer in c language

                                                          Pointer A pointer is a drivided class.It is built from one of the fundamental data type available in c.Pointer contain memory addresses as their values.since these memory addresses are the locations in the computer memory where program instructions and data are stored.Pointer can be used to access and manuplates data store in the memory. Pointer decleartion :- A=[10] Where a is variable name. 10 is the value of variable. Adderss of variable(suppose) 65524. *p – pointer symbol Pointer program :- #include<stdio.h> #include<conio.h> Void main() { Int a ; Int *p ; Printf(“enter a no”); Scanf(“%d”,&a); P=&a; Printf(“\n value of variable %d=”,a); Printf(“\n value of variable %d=”,*p); Printf(“\n addres of variable %u=”,&a); ...

Friend function in c++

                                                                  FRIEND FUNCTION We know that private member cannot be access from out side the class.That is a non member function cannot have an access to the private data of a class,but there may be some situation where we would like two classes to share a particular function.In such situation c++ allows the common function to be made friendly with both the classes,that allows to have access to the private data of these classes.Such a function need not be a function of any of these classes. To declear a friend function the function decided by  the keyword friend.the definition does not used the keyword friend or the scope resulation operator(::) .A function can be decleare as a friend in any number of classes.All the a friend function of class is a but i...