facts about c++


constructor is a special type of function or method in which there is No return type(Even void) and constructor name will be same as the name of the class.

There are two types of constructor
1.default constructor
2.parameterised constructor

Passing Objects as Function Arguments in C++
class Test
public :

/*here we are passing Test the name of the class as argument as we are going to pass objects as argument
this is the syntax of Passing Objects as Function Arguments*/

void display(Test)

//here we are passing t with Test as we are Passing Object (t) as Function Arguments.

void Test :: display(Test t) //

Friend function

A C++ friend functions are special functions which can access the private members of a class. 

friend function are defined with the keyword friend 

friend function return type Function name(class name);

friend function is not a member of class so we don’t need to write class_name or use use scope resolution operator(::) like this class_name::function_name(). we simply write friend function as normal functions. 

Leave a Comment

Your email address will not be published. Required fields are marked *

Open chat