Object Oriented Programming

Friend Functions

Friend functions

In this part you will learn: 1. What are friend functions 2. Uses of friend function 3. Syntax of friend function 4. Program 5. Output Friend Function A function declared as friend function isn’t really a part of member functions of a class but it can access the public as well as the private members of the class which considers the function as its friend.

Constant members and Objects

Constant members and Objects

In this part you will learn: 1. What are constant data members and functions 2. How to use them 3. Syntax in c++ 4. Program 5. Output Constant data members Constant data members are the data members of a class which once initialized, cannot be changed during any part of the program. Constant data members are declared just like normal data member declaration, the only difference is that we add a keyword ‘const’ before it.

Member Function’s Definition Outside Class

Member function’s definition outside Class

In this part you will learn: 1. Why we need to define function outside class 2. Syntax 3. Scope resolution operator 4. Program Defining Member function outside Class Till now, we have written many programs using class in the previous topic. In those classes, we had member functions too. Those member functions were defined right there because of their small size. But think about a huge project, with hundreds of member functions of a single class.

Passing and Returning of Objects To and From Functions

Passing and Returning of objects to/from Functions

In this part you will learn: 1. How to pass objects to a function 2. Arrow operator 3. Syntax of passing an object 4. How to return an object from a function 5. Syntax of returning an object 6. Program with object passing and returning 7. Output Passing an Object to Function Just like built-in data types like int, char, float , user-defined class’s object can be passed to a function in c++.

Static Data Members

Static data members

In this part you will learn: 1. What is static data member? 2. Where static data members are used? 3. Syntax of Static data members 4. Writing program with Static data members 5. Showing output Static data member Static data members are those data members which retain their values, i.e. Static data members store the latest value in them so that the value will be used for next time when the function that makes use of static data member is called.

Copy Constructor

Copy Constructor

In this part you will learn: 1. What is copy constructor? 2. Usage of copy constructor 3. Syntax of Copy Constructor 4. Writing program with copy constructor 5. Showing output Copy Constructor A copy constructor is a special constructor that initializes a new object from an existing object.

Constructor and Destructor

Constructor and Destructor

In this part you will learn: 1. What are Constructor and Destructor? 2. Types of Constructor 3. Syntax of Constructor and Destructor 4. Writing program with constructor and destructor 5. Showing output Constructor Constructor is a function of the class which is called at initialization or declaration of an object. To initialize values to the members of the function we use this function.

Setters And Getters

Setters and Getters

In this part you will learn: 1. What are setters and getters? 2. Why we need setters and getters? 3. Program using setters and getters 4. Showing output What are Setters and Getters? As the name suggests, setters are functions used to set values whereas getters are used to get values. Setters and getters functions are usually public data members of the class. Setters and getters are used for private or protected member variables.

More About Access Specifiers

In this part you will learn: 1. Types of access specifier 2. Different uses of different access specifiers 3. Using access specifiers in Code Types of Access Specifiers As we have discussed earlier, there are three types of access specifier we use in c++ which are given below. • Private • Public • Protected Private This is the access specifier which is set as default. i.e when the programmer doesn't give the access specifier. C++ considers it as a private.

Getting Started With Object Oriented Programming

In this part you will learn: 1. Why we need Object Oriented Programming approach? 2. Classes 3. Access specifiers 4. First program using Classes 5. Dot operator 6. Showing output Why we need Object Oriented Programming approach? As we have already learned in c how to perform different operations and process information, using that ways we can write small programs but if we are writing programs for very large projects this approach isn’t really a good one.