Question:medium

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

The Correct Option is B

Solution and Explanation

Step 1: Recall the two places an object can live in C++.
An object can be created directly on the stack, simply by declaring it like any ordinary variable, for example MyClass obj;, or it can be created dynamically on the heap, where its lifetime is controlled manually by the programmer.
Step 2: Focus on the dynamic case, since that is what needs a keyword.
To create an object on the heap, C++ provides a dedicated operator, new. Writing MyClass ptr = new MyClass(); asks the runtime to allocate memory for the object on the heap and returns a pointer to it, this is the specific keyword C++ reserves for dynamic object creation.
Step 3: Eliminate the made up options.
create, object, and call are not reserved keywords in C++ at all, none of them trigger object creation, they are simply not part of the language's syntax for this purpose.
Step 4: Conclude.
The keyword used for dynamically defining an object in C++ is
\[ \boxed{\text{new}} \]
Was this answer helpful?
0