ฉันได้ลองหลายตัวเลือกแล้ว แต่คอมไพเลอร์ของฉันไม่รับโอเปอเรเตอร์ที่โอเวอร์โหลดหรือมีอย่างอื่นผิดปกติ ฉันใช้ XCode 4.5.2 กับคอมไพเลอร์ Apple LLVM 4.1 เริ่มต้น
ข้อผิดพลาดที่ฉันได้รับคือ: Assigning to 'cocos2d::CCString *' from incompatible type 'const char [5]'
ในบรรทัดเหล่านี้:
CCString *s_piece__locks = "TEST";
cocos2d::CCString *s_piece__locks2 = "TEST";
รหัส .h ของฉัน:
CCString& operator= (const std::string& str);
// CCString& operator= (const char* str); // this doesn't work either
const CCString& operator = (const char *);
รหัส .cpp ของฉัน (แม้ว่าจะไม่เกี่ยวข้องก็ตาม):
CCString& CCString::operator= (const std::string& str)
{
m_sString = CCString::create(str)->m_sString;
return *this;
}
const CCString& CCString :: operator = (const char* str)
{
m_sString = CCString::create(str)->m_sString;
return *this;
}
ความช่วยเหลือของคุณได้รับการชื่นชมอย่างมาก ขอบคุณ!
char[]
ให้กับ ตัวชี้ ให้กับCCString
- person Angew is no longer proud of SO   schedule 10.01.2013