//https://[Log in to view URL]
/*
class : car
data members : color,weight,speed,model
methods : startcar(),break(),change gear(),speedup()
*/
#include<iostream>
#include<string>
using namespace std;
#if 0
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;
}
#endif
class car{
public:
int no;
string model;
};
int main(){
car volvo,tesla,farrari;
volvo.no=1;
volvo.model=" s1";
tesla.no=2;
tesla.model=" x1";
farrari.no=3;
farrari.model=" f1";
cout<<volvo.no<<volvo.model<<"\n";
cout<<tesla.no<<tesla.model<<"\n";
cout<<farrari.no<<farrari.model<<"\n";
}
To embed this project on your website, copy the following code and paste it into your website's HTML: