이 하나의 클래스는 int health
및 int level
과 같은 변수 속성 만 있지만 protected
이지만 메소드는 없습니다. 이 나쁜 습관인가? 나는 이것을 세이브 게임 기능에 사용하고 있으며 변수를 사용할 필요가 있지만 메서드가 필요하지 않습니다. 파일은 다음과 같이 :C++에서 변수 속성 만있는 클래스를 만드는 것은 나쁜 습관입니까?
Human.h :
// Human.h - Johnny P
#pragma once
namespace SharpEngine {
class Human {
protected:
std::string name;
int level;
int health;
int defense;
int strength;
int experience;
int money;
int inventory[10];
};
}
Human.cpp
// Human.cpp - Johnny P
#include <string>
#include "Human.h"
구조체를 사용하지 않는 이유는 무엇입니까? –
@MaxE. 왜 수업을 사용하지 않습니까? –
머리 글자 어는 POD = plain old data이며, 보통'class'보다는'struct'를 사용합니다. – dmckee