Run ❯
Get your
own
website
❯
Run Code
Ctrl+Alt+R
Change Orientation
Ctrl+Alt+O
Change Theme
Ctrl+Alt+D
Change Language
Go to Spaces
Ctrl+Alt+P
#include
#include
using namespace std; class Player { public: string name; int score = 0; void addScore(int score) { this->score += score; } }; int main() { Player p1; p1.name = "Liam"; p1.addScore(10); p1.addScore(5); cout << p1.name << " has " << p1.score << " points"; return 0; }
Liam has 15 points