#include <iostream> using namespace std; class MyClass { public: int number; void display(); }; void MyClass::display() { for(int i = 0; i<= number;i++) { cout<< "Hello World \n"; } } int main () { MyClass myfirstobject; myfirstobject.number =3; myfirstobject.display(); return 0; }
Hello World Hello World Hello World Hello World