Question: Which statement generates an error? Why? class Players { public: void SetName ( string newName ) { . . . } void SetAge ( int
Which statement generates an error? Why?
class Players
public:
void SetNamestring newName
void SetAgeint newAge
;
class SoccerPlayers: public Players
public:
void SetDetailsstring newName
string GetLeague
;
int main
String leagueName;
Players newPlayers;
SoccerPlayers playerObject;
playerObject.SetNameTim Allen";
playerObject.SetAge;
leagueName newPlayers.GetLeague;
return ;
playerObject.SetNameTim Allen";
will generate an error as as SetName is not declared in class SoccerPlayers.
SoccerPlayers playerObject;
will generate an error as an object of derived class cannot be created.
leagueName newPlayers.GetLeague;
will generate an error as GetLeague is not a member of Players class.
Players newPlayers;
will generate an error as an object of base 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
