Sundus
2
Q:

creating classes c++


  class MyClass {       // The class
  public:             
  // Access specifier
    int myNum;        // 
  Attribute (int variable)
    string myString;  // 
  Attribute (string variable)
};

int main() {
  MyClass myObj;  
  // Create an object of MyClass

  // Access attributes and set values
  myObj.myNum 
  = 15; 
  
  myObj.myString = "Some text";

  // Print attribute values
  
  cout << myObj.myNum << "\n"; 
  cout << myObj.myString; 
  return 0;
}

  
1
TYPE& dynamic_cast<TYPE&> (object);
TYPE* dynamic_cast<TYPE*> (object);
-3

New to Communities?

Join the community