Create an Object in c++
An object in C++ is created from a class. Now that the class 'Myclass' has been developed, we can use it to create objects.
To create a "Myclass" object, type the class name first, then the object name.
class Myclass { // Create The class
public: // Access specifier two types public and private
int num;
string MyString;
};
int main() {
Myclass Obj; // Create an object of Myclass
// Access attributes and set values
Obj.num = 15;
Obj.MyString = "Some text";
// Print attribute values
cout << Obj.Num << "\n";
cout << Obj.MyString;
return 0;
}