初学者,正在阅读火烈鸟的《Cocos2d-x高级开发教程》(https://app.box.com/s/e3hbjgyvaqx4w5lh9ffb),阅读到下面截图中的段落
问题1:上面这段代码应该添加在AppDelegate.h还是AppDelegate.cpp中?
我添加在AppDelegate.cpp中后运行,有以下输出
— Begin quote from ____
1>------ 已启动生成: 项目: HelloWorld, 配置: Debug Win32 ------
1> main.cpp
1> AppDelegate.cpp
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.cpp(7): error C2146: 语法错误: 缺少“;”(在标识符“m_msg”的前面)
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.cpp(7): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.cpp(10): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.cpp(10): error C2143: 语法错误 : 缺少“,”(在“&”的前面)
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.cpp(10): error C2065: “msg”: 未声明的标识符
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.cpp(10): error C2614: “LifeCircleLogger”: 非法的成员初始化:“m_msg”不是基或成员
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.cpp(11): error C2065: “m_msg”: 未声明的标识符
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.cpp(11): error C2228: “.c_str”的左边必须有类/结构/联合
1> 类型是“‘unknown-type’”
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.cpp(13): error C2065: “m_msg”: 未声明的标识符
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.cpp(13): error C2228: “.c_str”的左边必须有类/结构/联合
1> 类型是“‘unknown-type’”
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.cpp(18): error C2440: “”: 无法从“const char ”转换为“LifeCircleLogger”
1> 无构造函数可以接受源类型,或构造函数重载决策不明确
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.cpp(26): error C2440: “”: 无法从“const char ”转换为“LifeCircleLogger”
1> 无构造函数可以接受源类型,或构造函数重载决策不明确
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.cpp(50): error C2440: “”: 无法从“const char ”转换为“LifeCircleLogger”
1> 无构造函数可以接受源类型,或构造函数重载决策不明确
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.cpp(59): error C2440: “”: 无法从“const char ”转换为“LifeCircleLogger”
1> 无构造函数可以接受源类型,或构造函数重载决策不明确
1> 正在生成代码…
========== 生成: 成功 0 个,失败 1 个,最新 5 个,跳过 0 个 ==========
— End quote
我添加到AppDelegate.h中后运行,有以下报错
— Begin quote from ____
1>------ 已启动生成: 项目: HelloWorld, 配置: Debug Win32 ------
1> main.cpp
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(38): error C2146: 语法错误: 缺少“;”(在标识符“m_msg”的前面)
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(38): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(41): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(41): error C2143: 语法错误 : 缺少“,”(在“&”的前面)
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(41): error C2065: “msg”: 未声明的标识符
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(41): error C2614: “LifeCircleLogger”: 非法的成员初始化:“m_msg”不是基或成员
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(42): error C2065: “m_msg”: 未声明的标识符
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(42): error C2228: “.c_str”的左边必须有类/结构/联合
1> 类型是“‘unknown-type’”
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(42): error C3861: “CCLog”: 找不到标识符
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(44): error C2065: “m_msg”: 未声明的标识符
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(44): error C2228: “.c_str”的左边必须有类/结构/联合
1> 类型是“‘unknown-type’”
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(44): error C3861: “CCLog”: 找不到标识符
1> AppDelegate.cpp
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(38): error C2146: 语法错误: 缺少“;”(在标识符“m_msg”的前面)
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(38): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(41): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(41): error C2143: 语法错误 : 缺少“,”(在“&”的前面)
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(41): error C2065: “msg”: 未声明的标识符
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(41): error C2614: “LifeCircleLogger”: 非法的成员初始化:“m_msg”不是基或成员
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(42): error C2065: “m_msg”: 未声明的标识符
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(42): error C2228: “.c_str”的左边必须有类/结构/联合
1> 类型是“‘unknown-type’”
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(42): error C3861: “CCLog”: 找不到标识符
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(44): error C2065: “m_msg”: 未声明的标识符
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(44): error C2228: “.c_str”的左边必须有类/结构/联合
1> 类型是“‘unknown-type’”
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.h(44): error C3861: “CCLog”: 找不到标识符
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.cpp(9): error C2440: “”: 无法从“const char ”转换为“LifeCircleLogger”
1> 无构造函数可以接受源类型,或构造函数重载决策不明确
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.cpp(17): error C2440: “”: 无法从“const char ”转换为“LifeCircleLogger”
1> 无构造函数可以接受源类型,或构造函数重载决策不明确
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.cpp(41): error C2440: “”: 无法从“const char ”转换为“LifeCircleLogger”
1> 无构造函数可以接受源类型,或构造函数重载决策不明确
1>f:\cocos2d-x-2.2.1\projects\helloworld\classes\appdelegate.cpp(50): error C2440: “”: 无法从“const char ”转换为“LifeCircleLogger”
1> 无构造函数可以接受源类型,或构造函数重载决策不明确
1> 正在生成代码…
========== 生成: 成功 0 个,失败 1 个,最新 5 个,跳过 0 个 ==========
— End quote

