0% found this document useful (0 votes)
39 views1 page

Virtual Functions

The document contains C++ class definitions for an 'Entity' class and a derived 'Player' class. Both classes have private member variables for coordinates and a public method 'Print' to output these coordinates. There are errors in the code such as incorrect access specifiers and variable names that need to be corrected for proper functionality.

Uploaded by

X GAMING
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views1 page

Virtual Functions

The document contains C++ class definitions for an 'Entity' class and a derived 'Player' class. Both classes have private member variables for coordinates and a public method 'Print' to output these coordinates. There are errors in the code such as incorrect access specifiers and variable names that need to be corrected for proper functionality.

Uploaded by

X GAMING
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

class Entity

{
privat:
int m_X,m_Y;
public:
virtual void Print() {
cout << x << "," <<y << endl;
}
};
class Player : public Entity
{
privat:
int m_X,m_Y;
public:
Player(int x, int y) {
m_X = x;
m_Y = y;
}
void Print() override //that means the existence of a similar method in a
class that this class is inherent from.
{
cout << x << "," <<y << endl;
//static methods deal only with static var
}
};

You might also like