Anonymous Object in C++

Anonymous Object is a Object without any name. In a C++ programming an object are created with names but It is still possible to create object without name such object are known as anonymous object. When constructor and destructor are called, the data members are initialize and destroyed respectively. Without object we can initialize and … Read more

Function Overriding in C++ with Example

Function Overriding in C++ Programming Language is one of the important concept in C++. Function Overloading is used to achieve run time polymorphism What is Function Overriding in C++? When two classes are in inheritance hierarchy. Then parent class function is re-defined in child class with same method signature. The re defined function in child … Read more

Categories C++

C++ program for student details using array of objects

Array of Objects in C++ Array of Object is similar to creating array or integer, character or any primitive data types. Example Array of integer is int age[5]={1,2,3,4,5}; Similar way array of Student is Student s[5]={studentObj1,studentObj2,studnetObj3,studentObj4,studentObj5}; Student is class Name s is array of objects of 5 elements To initialize student object two methods are … Read more

Categories C++

Single and Multidimensional Arrays in C++

Arrays is a kind of data structure that can store a elements of the same type. Arrays stores the elements in a contiguous memory locations. Array is a collection of variables of the same type.  For example: we want to declare 100 integer variable Instead of declaring 100 individual variables, such as int number0, number1,number2,number3, … Read more

Categories C++

File Handling in C++

File In a computer system files are used to store the necessary information / data stored. There are mainly two types of files: Text file Binary file Text file. It stores information/data in ASCII characters. In text files, each line of text is terminated with a special character known as EOL (End of Line) character. … Read more

Categories C++

Exception Handling in C++

In C++ programming, an exception is an abnormal condition that arises/occurs in a source code during run time.   Or  Exception is a run time error.   Example:

Output

When we try to compile this program we will receive an error message because value of 100/a (100/0) is infinite and it can’t be possible to … Read more

Categories C++

Template in C++

In  C++ programming language, Template is used to declare a group of function or class in a generic manner. Generic  means that that can process all types of data. By using template a single function can defined for a group of functions, it is called as a “function template”. Similarly, when template is associated with … Read more

Categories C++

Abstract Class in C++

In a C++ programming language , a class that contains at least one pure virtual function is called  abstract class. This  pure virtual function is a function is declared within base class and defined by derived class. Like a other class abstract class can also contains normal function. We can not create object of an … Read more

Categories C++

Virtual Function in C++

In a C++ programming language, A virtual function is a member function that is declared and defined within a base class and redefined by a derived class even if the number and type of argument are matching.   Rules for Virtual Function:  A virtual function may be declared as friend for another class.   Constructor cannot be … Read more

Categories C++

Constructor and Destructor Calling in C++

In a C++ programming language constructor are called from base class to derived class and destructor are called reverse of constructor means from derived class to base class.                                                                                                                       Example:   Write a program to show the sequence of execution of constructor and destructor.

Output

Categories C++