31.1k views
3 votes
In GamePoints' constructor, assign teamWhales with 500 and teamLions with 500. #include using namespace std; class GamePoints { public: GamePoints(); void Start() const; private: int teamDolphins; int teamLions; }; GamePoints::GamePoints() : /* Your code goes here */ { } void GamePoints::Start() const { cout << "Game started: Dolphins " << teamDolphins << " - " << teamLions << " Lions" << endl; } int main() { GamePoints myGame; myGame.Start(); return 0; }

1 Answer

4 votes

Answer:

Here is the GamePoints constructor:

GamePoints::GamePoints() :

/* Your code goes here */

{

teamLions = 500;

teamDolphins = 500;

}

Step-by-step explanation:

Here is the complete program:

#include //to use input output functions

using namespace std; //to identify objects like cin cout

class GamePoints { //class GamePoints

public: GamePoints(); // constructor of GamePoints class

void Start() const; //method of GamePoints class

private: //declare data members of GamePoints class

int teamDolphins; // integer type private member variable of GamePoints

int teamLions; }; // integer type private member variable of GamePoints

GamePoints::GamePoints() //constructor

{ teamLions = (500), teamDolphins= (500); } //assigns 500 to the data members of teamLions and teamDolphins of GamePoints class

void GamePoints::Start() const { //method Start of classs GamePoints

cout << "Game started: Dolphins " << teamDolphins << " - " << teamLions << " Lions" << endl; } //displays the values of teamDolphins and teamLions i.e. 500 assigned by the constructor

int main() //start of main() function

{ GamePoints myGame; // creates an object of GamePoints class

myGame.Start(); //calls Start method of GamePoints class using the object

return 0; }

The output of the program is:

Game started: Dolphins 500 - 500 Lions

User The Bearded Llama
by
6.4k points