+ 1
Whats the advantage of "class" if a simple program gives the same output..??
i mean the following two programs have same output: 1). #include <iostream> using namespace std; class myClass { public: myClass() { cout <<"Hey"; } void setName(string x) { name = x; } string getName() { return name; } private: string name; }; int main() { myClass myObj; return 0; } 2). #include<iostream> using namespace std; int main() { cout<<"Hey"; return 0; }
1 Réponse
+ 8
Short answer: None. It's redundant. A class represents a blueprint of an object which has its own attributes. The example provided doesn't necessitate the use of classes.