Question: The following code generates an error. Why? class Player { public: void SetName ( string newName ) { . . . } private: void SetAge
The following code generates an error. Why?
class Player
public:
void SetNamestring newName
private:
void SetAgeint newAge
;
class SoccerPlayer: public Player
public:
void SetDetailsstring newName
string GetLeague
;
int main
string leagueName;
SoccerPlayer playerObject;
playerObject.SetNameTim Allen";
playerObject.SetAge;
leagueName playerObject.GetLeague;
Group of answer choices
playerObject.SetAge
will generate an error as SetAge is private member which is not inherited by the SoccerPlayers class.
leagueName playerObject.GetLeague
will generate an error as the derived class should not call its own members.
playerObject.SetNameTim Allen"
will generate an error as SetName is not declared in class SoccerPlayers.
SoccerPlayer playerObject
will generate an error as an object of derived class cannot be created.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
