Tutorials

Object-Oriented Programming In C++: Constant Objects

Submitted by PhoeniciansSy on

Contents:

1. Constant Variables.

2. Constant Member Functions.

Constant Variables:

Making variables constant ensures their values are not accidentally changed. Just like the built-in data types (int, double, char, etc…), class objects can be made const by using the const keyword.

Object-Oriented Programming In C++: Destructor

Submitted by PhoeniciansSy on

Contents:

1. Destructor.

2. When Constructors and Destructors are Called.

Destructor

Is a member function in the class, which has the following characteristics: 1. It has the same name as the class preceded with a tilde '~'. For example, the destructor for class Time is declared: ~Time() 2. It doesn't return any type. 3. It is called when objects are destroyed to release all allocated resources. 4.

Object-Oriented Programming in C++: Constructors

Submitted by PhoeniciansSy on

Contents:

1. Constructors. 2. Default Constructors. 3. Constructors with Arguments. 4. Time Class with Constructors.

Constructors:

Constructor is a member function in the class, which has the following characteristics: 1. It has the same name as the class. 2. It doesn't return any type. 3. It is called every time an instance of a class is created. 3.

Object-Oriented Programming In C++: Overloading and Default Arguments

Submitted by PhoeniciansSy on

Content:

1. Function overloading in C++. 2. Default arguments in c++.

Function Overloading in C++:

We can have multiple definitions for the same function name in the same scope. The definition of the function must differ from each other by the types and/or the number of arguments in the argument list. We can not overload function declarations that differ only by return type. Example: We can define a function called display to print a integer number.