Q. Which of the following is the correct way to create an object of a class in C++?

  • (A) class obj;
  • (B) obj = new class;
  • (C) class obj = new class();
  • (D) ClassName obj;
πŸ’¬ Discuss
βœ… Correct Answer: (D) ClassName obj;
Explanation: In C++, objects are created using the class name followed by the object name, like 'ClassName obj;'.
Explanation by: Rakesh Kumar
In C++, objects are created using the class name followed by the object name, like 'ClassName obj;'.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
154
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Rakesh Kumar
Publisher
πŸ“ˆ
81%
Success Rate