나는 단순한 bool 포인터 클래스 멤버를 사용합니다. 거짓 응답 할당. true는 다른 동작을합니다. 코드의 주석을 참조하십시오. 아래 다른 하나를 테스트하기 위해 하나를 주석 처리하십시오.bool 포인터 멤버 동작이 true와 vs가 다를 때
나는 변환이 false
에서 0
에 존재하기 때문에입니다 컴파일러 호출 g++ -o basic basic.cpp
class Test
{
public:
int a;
bool* abool;
};
int main() {
Test t;
//t.abool = false; // WORKS
//t.abool = true; // ERROR: cannot convert 'bool' to 'bool*' in assignment - expected IMO;
// this should work for both values IMO
//*(t.abool) = true; // Segmentation fault
//*(t.abool) = false; // Segmentation fault
cout << t.abool << endl;
return 0;
}
있어. thx 얘들 아! – groovehunter