This program fails to compile(using gcc-4.5). The error message says:
error: ‘myType_t’ does not name a type
1 class abc{
2 //typedef int myType_t;
3
4 public:
5 typedef int myType_t;
6
7 abc();
8 myType_t fun1();
9 };
10
11 myType_t abc::fun1()
12 {
13 return 0;
14 }
15
16 int main()
17 {
18 abc abc1;
19 return 0;
20 }
Now declaring typedef int myType_t;
outside the class abc
makes this compile.
My confusion is, what is the problem if the return type of a member function is typedef'd inside the class.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…