📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!


    Question

    Which of the following is a valid C++

    constructor?
    A void ClassName() {} Correct Answer Incorrect Answer
    B ClassName() {} Correct Answer Incorrect Answer
    C ~ClassName() {} Correct Answer Incorrect Answer
    D Constructor() {} Correct Answer Incorrect Answer
    E new ClassName() {} Correct Answer Incorrect Answer

    Solution

    Constructors have the same name as the class, no return type, and can initialize objects.

    Practice Next
    ask-question