Skip to main content

Posts

Showing posts from 2017

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 ...

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...