Skip to content

Tag Archives: C++-Class and Object

Pointers are the variable that stores the address of another variable is called a pointer. The pointer of Base Class pointing different object of derived… Read More
Array of Objects:It is an array whose elements are of the class type. It can be declared as an array of any datatype. Syntax: classname… Read More
In Object Oriented Programming, Objects are the instances of a class which has its own state(variables) and behavior(methods). Every class has two special methods related… Read More
Prerequisites: Access Modifiers in C++, Runtime Polymorphism Private: The class members declared as private can be accessed only by the functions inside the class. They… Read More
We all are familiar with an alias in C++. An alias means another name for some entity. So, a reference variable is an alias that… Read More
Array of Objects: When a class is defined, only the specification for the object is defined; no memory or storage is allocated. To use the data… Read More
Virtual base classes are used in virtual inheritance in a way of preventing multiple “instances” of a given class appearing in an inheritance hierarchy when… Read More
We can create an object of one class into another and that object will be a member of the class. This type of relationship between… Read More
There are two parts of memory in which an object can be stored: stack – Memory from the stack is used by all the members… Read More
Anonymous class is a class which has no name given to it. C++ supports this feature. These classes cannot have a constructor but can have… Read More
Which of the following is true about the following program #include <iostream> class Test { public:     int i;     void get(); }; void Test::get() {     std::cout… Read More
Assume that an integer and a pointer each takes 4 bytes. Also, assume that there is no alignment in objects. Predict the output following program.… Read More
Which of the following is true? (A) All objects of a class share all data members of class (B) Objects of a class do not… Read More
class Test {     int x;  }; int main() {   Test t;   cout << t.x;   return 0; } (A) 0 (B) Garbage Value (C) Compiler Error… Read More
Predict the output of following C++ program #include<iostream> using namespace std;     class Empty {};     int main() {   cout << sizeof(Empty);   return 0; }… Read More