why we are using this lendthy method? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

why we are using this lendthy method?

#include <iostream> using namespace std; class MyClass { public: MyClass(); void myPrint(); }; MyClass::MyClass() { } void MyClass::myPrint() { cout <<"Hello"<<endl; } int main() { MyClass obj; obj.myPrint(); } we can also use only- #include<iostream> using namespace std; int main() { cout << "Hello World"<<endl; return 0; }

27th Jun 2019, 11:59 AM
Nitin Diwakar
Nitin Diwakar - avatar
1 Answer
+ 1
I think it's just an example of implementing a class in C++ and not the real-world implementation
27th Jun 2019, 12:13 PM
Agent_I
Agent_I - avatar