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;
2 Antworten
+ 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.
0
Thanks