0

What is myClass myObj ?

#include <iostream> #include <string> using namespace std; class myClass { public: string name; }; int main() { myClass myObj; myObj.name = "SoloLearn"; cout << myObj.name;

26th Jun 2018, 4:57 PM
Aashutosh Swami
Aashutosh Swami - avatar
2 Answers
+ 1
myClass is a blueprint for constructing a object of type "myClass". myObj is a structure, that has all attributes (name here) and methods (none methods here) defined in myClass scope. myClass myObject command is declaring an object using myClass blueprint. ItÂŽs similar to declariong primitive data types, such as "int h". myClass and int are both data types and myObj and h are names for the variable/object.
26th Jun 2018, 5:32 PM
Jan Ơtěch
Jan Ơtěch - avatar
0
Thanks
4th Jul 2018, 12:19 PM
Aashutosh Swami
Aashutosh Swami - avatar