分文件类外定义为什么会报错啊?
按照老师的代码写的,不知道为什么报错了,报的错也看不懂QAQ。但是如果我在头文件上加#include<...>那几行 就能正常运行了,为什么啊?这样做对不对啊?



按照老师的代码写的,不知道为什么报错了,报的错也看不懂QAQ。但是如果我在头文件上加#include<...>那几行 就能正常运行了,为什么啊?这样做对不对啊?



2016-06-13
1>------ 已启动生成: 项目: text, 配置: Debug Win32 ------
1>生成启动时间为 2016/11/23 16:46:32。
1>InitializeBuildStatus:
1> 正在创建“Debug\text.unsuccessfulbuild”,因为已指定“AlwaysCreate”。
1>ClCompile:
1> demo.cpp
1>c:\users\john\desktop\text\demo.cpp(9): error C2065: “Teacher”: 未声明的标识符
1>c:\users\john\desktop\text\demo.cpp(9): error C2146: 语法错误: 缺少“;”(在标识符“t”的前面)
1>c:\users\john\desktop\text\demo.cpp(9): error C2065: “t”: 未声明的标识符
1>c:\users\john\desktop\text\demo.cpp(10): error C2065: “t”: 未声明的标识符
1>c:\users\john\desktop\text\demo.cpp(10): error C2228: “.setName”的左边必须有类/结构/联合
1> 类型是“'unknown-type'”
1>c:\users\john\desktop\text\demo.cpp(11): error C2065: “t”: 未声明的标识符
1>c:\users\john\desktop\text\demo.cpp(11): error C2228: “.setGender”的左边必须有类/结构/联合
1> 类型是“'unknown-type'”
1>c:\users\john\desktop\text\demo.cpp(12): error C2065: “t”: 未声明的标识符
1>c:\users\john\desktop\text\demo.cpp(12): error C2228: “.setAge”的左边必须有类/结构/联合
1> 类型是“'unknown-type'”
1>c:\users\john\desktop\text\demo.cpp(13): error C2065: “t”: 未声明的标识符
1>c:\users\john\desktop\text\demo.cpp(13): error C2228: “.getName”的左边必须有类/结构/联合
1> 类型是“'unknown-type'”
1>c:\users\john\desktop\text\demo.cpp(13): error C2065: “t”: 未声明的标识符
1>c:\users\john\desktop\text\demo.cpp(13): error C2228: “.getGender”的左边必须有类/结构/联合
1> 类型是“'unknown-type'”
1>c:\users\john\desktop\text\demo.cpp(13): error C2065: “t”: 未声明的标识符
1>c:\users\john\desktop\text\demo.cpp(13): error C2228: “.getAge”的左边必须有类/结构/联合
1> 类型是“'unknown-type'”
1>c:\users\john\desktop\text\demo.cpp(14): error C2065: “t”: 未声明的标识符
1>c:\users\john\desktop\text\demo.cpp(14): error C2228: “.teach”的左边必须有类/结构/联合
1> 类型是“'unknown-type'”
1>
1>生成失败。
1>
1>已用时间 00:00:01.46
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
举报