Question:

Which keyword is used to define an object in C++?

Show Hint

In C++, remember that every object created withnew` must be explicitly destroyed withdelete` to prevent memory leaks. For example:delete myPtr;`.
Updated On: Jul 2, 2026
  • create
  • new
  • object
  • call
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

In C++, an object is an instance of a class. There are two main ways to create an object:
1. Static Allocation (on the stack): You can declare an object just like a variable. MyClass myObject;` This creates an object namedmyObject` on the stack.
2. Dynamic Allocation (on the heap): You can create an object in heap memory using thenew` keyword. This returns a pointer to the newly created object. MyClass myPtr = new MyClass();`
The question asks which keyword is used.
(A)create` is not a C++ keyword for object creation. (B)new` is the C++ keyword used specifically for dynamic memory allocation and object creation on the heap. (C)object` is a concept, not a keyword for creation. (D)call` is not a C++ keyword for object creation.
While objects can be defined withoutnew`, thenew` keyword is the specific operator used for dynamic object definition/creation. Given the options,new` is the correct answer.
Was this answer helpful?
0
0