#include <iostream>
class Entity
{
public:
float X, Y;
void Move(float xa, float ya)
{
X += xa;
Y += ya;
}
};
class Player : public Entity
{
public:
const char* m_Name;
void PrintName()
{
std::cout << m_Name << std::endl;
}
};
int main(void)
{
std::cout << sizeof(Entity) << std::endl;
std::cout << sizeof(Player) << std::endl;
Player player;
player.Move(5.0f, 8.0f);
player.X = 4;
std::cin.get();
}
【Cherno的C++视频】Inheritance in C++
最新推荐文章于 2024-07-29 13:48:22 发布