c++ class constructor

C++
class MyClass {
   public:
      MyClass();  // This is the constructor
   private:
      int someInt;
};

MyClass::MyClass(void) {
   someInt = 1;
}  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;
}

  
Source

Also in C++: