안녕하세요. 무자비한 커뮤니티입니다.C++ Union/Struct 'printColorPicker :: printColorPicker (void)': 삭제 된 함수를 참조하려고 시도했습니다.
이 오류가 라인 (20)에있는 멍청한 놈의 코드
을 보라하시기 바랍니다 (난 당신이 볼 수 있도록 그것을 언급하겠습니다).
오류 : 'printColorPicker :: printColorPicker (무효)'
#include <iostream>
using namespace std;
enum availableColors {
incolorPrint,
colorPrint
};
union printColorPicker {
struct incolorPrint {
int id;
char* details = "No color ink eh?";
} i;
struct colorPrint{
int id;
char* details = "Unicorn mode on";
} c;
} color; //line 20
void colorPicker(availableColors c){
char* option;
switch (c) {
case incolorPrint: {
option = color.i.details;
}
break;
case colorPrint: {
option = color.c.details;
}
break;
}
cout << option;
}
void main(){
colorPicker(colorPrint);
}
는 내가 뭘하려고 오전 내/cout을/printf와 문자열 에코 색상 선택기 방법을 사용하는 삭제 기능을 참조하기 위해 시도 구조체 (colorPrint
, incolorPrint
)는 printColorPicker
유니온 안에 있습니다.
위에서 언급 한 오류가 발생합니다.
그래서 생성자는 인수가없는'union'의 이름을 가져야합니까? –
TBH 필자는 왜 코드에서'union '을 사용하고 있는지 모르겠다. –
숙제입니다. 노동 조합이 요구 사항 중 하나입니다. –