Posts

Showing posts from July, 2020

Constructor C++

Image
Constructor C++                         Constructor is used to initailize the data members automatically.A constructor is a member function of class.It execute when object of that class created.It means that when object of class created the constructor executes automatically.By default there is constructor even if you dont write it.  Constructor Syntax                           The syntax of constructor is like same name of class e.g if the name of class is A so the constuctor will start with A(){ here is the body }. Copy Constructor C++                    Just read about copy constructor and assignment operator they can create a big problem in real world projects they cannot be used but for you should have some knowledge about it.

How To Use Class and Object In C++

Image
Class and Object In C++                             In C++ the concept of classes and objects is very useful.Now lets see how to use it and what is the syntax.Simply the class is written same as its name like class before the main method.Class with brackets like class{}.                                   Now lets take a look to object it is a logical thing.If you have class A and we want to create its object.We will do in main method A object; The A refers to class A and object refers to the object of class A.                                    Now lets create a function in class A.We have class A{} inside the brackets we will write public: just ignore what is this just write it for now after that in next line write void show(){ cout<<"Member function"<<endl;} Now we have create a function in a class.                                     Now we will call this function in main function with the object of class.After the A object in main just in next line write objec