Answers for "c++ construnctor"

C++
0

c++ construnctor

class MyClass {     // The class
  public:           // Access specifier
    MyClass() {     // Constructor
      cout << "Hello World!";
    }
};

int main() {
  MyClass myObj;    // Create an object of MyClass (this will call the constructor)
  return 0;
}
Posted by: Guest on October-13-2021

Browse Popular Code Answers by Language