쉽게 해결할 수있는 어색한 문제가 발생했지만 즐겁게 해결하지 못했습니다. 내 클래스의 생성자에서 데이터 멤버의 데이터 멤버를 초기화하고 있습니다. 여기에 몇 가지 코드 : 그러나데이터 구조체 멤버의 멤버 초기화
class Button {
private:
// The attributes of the button
SDL_Rect box;
// The part of the button sprite sheet that will be shown
SDL_Rect* clip;
public:
// Initialize the variables
explicit Button(const int x, const int y, const int w, const int h)
: box.x(x), box.y(y), box.w(w), box.h(h), clip(&clips[CLIP_MOUSEOUT]) {}
, 내가 말하는 컴파일러 오류가 발생합니다 :
C:\Users\Alex\C++\LearnSDL\mouseEvents.cpp|56|error: expected `(' before '.' token|
및
C:\Users\Alex\C++\LearnSDL\mouseEvents.cpp|56|error: expected `{' before '.' token|
이 방법으로 멤버를 초기화에 문제가 내가해야합니다 생성자 본문에서 할당으로 전환 하시겠습니까?
이러한 4 개의 매개 변수를 사용하고'SDL_Rect'를 반환하는 도우미 함수를 작성하십시오. 그런 다음 이니셜 라이저 목록에서 호출 할 수 있습니다. – jalf