contructor 바로 앞에있는 함수를 포함하는 클래스가 있는데, 그 자체는 비어 있습니다. 그게 전부입니다. 따라서 클래스는 함수와 일부 중요하지 않은 요소를 포함합니다.클래스 내부에있는 함수 사용하기
내가 원할 때만 함수를 그 함수에서 호출 할 수 있습니까? ClassName ObjectName
그리고 ObjectName.FunctionName
이 작동하지 않습니다.
typedef struct tiles
{
unsigned char red, green, blue;
}tiles;
const tiles BASE = {0,0,0};
const tiles TEST_ALIVE = {255,0,0};
const tiles CONWAY_ALIVE = {0,255,0};
const tiles CONWAY_DEAD = {0,50,0};
class Cellstruct
{
public:
Cellstruct(void);
virtual ~Cellstruct(void);
};
이것은 CPP 파일의 내용입니다 클래스에 속한다 (Cellstruct.cpp) :
이
헤더 파일의 내용이 클래스 (Cellstruct.h)에 속하는입니다#include "Cellstruct.h"
bool equality(tiles* a, const tiles* b)
{
if (a->red == b->red && a->green == b->green && a->blue == b->blue)
{
return true;
} else {
return false;
}
}
void Automaton(tiles arra[fullwidth][fullheight], tiles arrb[fullwidth][fullheight])
{
//*this is way too long so I cut it, I think it doesn't really matter*
}
Cellstruct::Cellstruct(void)
{
}
Cellstruct::~Cellstruct(void)
{
}
괜찮습니다. 게시물을 업데이트 해 주셔서 감사합니다. – taocp
함수를 어떻게 호출하고 오류를 표시 할 수 있습니까? – billz
'ObjectName.FunctionName'은'FunctionName'이 클래스의 멤버 함수라는 것을 의미합니다. 그것이 아니라면, 당신은 단순히 이런 식으로 할 수 없습니다. – taocp