#include <iostream>
using namespace std;
class SAM {
// properties
public:
int health;
char level;
int getHealth() {
return health;
}
char getLevel() {
return level;
}
void setHealth(int h) {
health = h;
}
void setLevel(char l) {
level = l;
}
};
int main() {
// Creating an object
SAM hero;
hero.setHealth(30);
hero.setLevel('A'); // Set level to a single character
cout << "His health is: " << hero.getHealth() << endl;
cout << "His level is: " << hero.getLevel() << endl;
return 0;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter