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 Students is Student s[5]={studentObj1,studentObj2,studnetObj3,studentObj4,studentObj5}; The student is class Name s is an array of objects of 5 elements To initialize the student object … Read more

Categories C++

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 the inheritance hierarchy. The parent class function is re-defined in the child class with the same method signature. The re-defined function … Read more

Categories C++

Anonymous Object in C++

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

Local and Nested Classes in C++

In a C++ language we can define a class within a function and such classes are called local classes. Local Classes in C++ Inside the local class, we can access the global and static variables. Local class can’t access the normal/nonstatic variable of a function.

Output

Description: In the above program, class B … Read more

Categories C++

Local object and global object in C++

In C++ objects can be classified as local object and global object. Local object A object defined inside a block is called local object. A local object can be inside block or function or class In above figure variable a and b are local variable inside complex class. Inside main function Complex c=Complex(1,2); is defined … Read more

Categories C++

c++ addition subtraction multiplication division with error

Here we will develop a C++ program for addition subtraction multiplication and division operations. following are the arithmetic operations in C++ programming. Sr No Operator Symbol Example 1 Addition + int result = num1 + num2; 2 Subtraction – int result = num1 – num2; 3 Multiplication * int result = num1 * num2; 4 … 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 an abstract class. This pure virtual function is declared within the base class and defined by a derived class. An abstract class in C++ is a class that cannot be instantiated directly and contains one or more pure … Read more

Categories C++

Size of the Object in C++

In a C++ programming language, the size of any object is equal to the sum of the size of all the class data members. In C++, the sizeof the operator returns the size of an object in bytes, including any padding added for alignment. The size of an object is determined by the sum of … Read more

Categories C++

Unions in C++

In a C++ programming language, the union is a special user-defined data type that allows to the storage of different data types in the same memory location. “union”  uses the same memory location for multiple-purpose.  Or In a union data type, a single variable, i.e., the same memory location, can be used to store multiple types … Read more

Categories C++

Constructor in C++

Constructor in C++ is similar to a function that has the same name as the class in which it resides. Constructor is automatically called when the object of that class created in which it is resides. A class can contain more than one constructor. Constructor does not have a return value. Characteristics of constructor Constructor … Read more

Categories C++