D
David Williams
Hi all, I get errors when compiling the .cpp file below, both on Visual
Studio and G++.
01: //-------------------------------------------------
02: template <typename Type>
03: class Outer
04: {
05: public:
06: Outer outerFunc(void);
07:
08: class Inner
09: {
10: public:
11: Outer innerFuncWorks(void);
12: Inner innerFuncBroke(void);
13: };
14: };
15:
16: template <typename Type>
17: Outer<Type> Outer<Type>:uterFunc()
18: {
19: }
20:
21: template <typename Type>
22: Outer<Type> Outer<Type>::Inner::innerFuncWorks()
21: {
23: }
24:
25: template <typename Type>
26: Outer<Type>::Inner<Type> Outer<Type>::Inner::innerFuncBroke()
27: {
28: }
29:
30: int main()
31: {
32: return 0;
33: }
34: //-------------------------------------------------
For example, G++ says:
Compiling: main.cpp
main.cpp:26: error: non-template type `Inner' used as a template
main.cpp:27: error: ISO C++ forbids declaration of `innerFuncBroke' with
no type
main.cpp:27: error: prototype for `int
Outer<Type>::Inner::innerFuncBroke()' does not match any in class
`Outer<Type>::Inner'
main.cpp:11: error: candidate is: Outer<Type>::Inner
Outer<Type>::Inner::innerFuncBroke()
main.cpp:27: error: template definition of non-template `int
Outer<Type>::Inner::innerFuncBroke()'
main.cpp: In member function `int Outer<Type>::Inner::innerFuncBroke()':
main.cpp:28: warning: no return statement in function returning non-void
Process terminated with status 1 (0 minutes, 0 seconds)
5 errors, 1 warnings
Essentially it appears to complain about the line where 'innerFuncBroke'
is defined. The only difference between this and 'innerFuncWorks' is the
return type, so this is presumably where the problem lies. I'm aware
that i'm returning no value and the compiler warns about that but it
doesn't appear to be the problem and i'm trying to keep the example simple.
Any ideas appriciated!
David
Studio and G++.
01: //-------------------------------------------------
02: template <typename Type>
03: class Outer
04: {
05: public:
06: Outer outerFunc(void);
07:
08: class Inner
09: {
10: public:
11: Outer innerFuncWorks(void);
12: Inner innerFuncBroke(void);
13: };
14: };
15:
16: template <typename Type>
17: Outer<Type> Outer<Type>:uterFunc()
18: {
19: }
20:
21: template <typename Type>
22: Outer<Type> Outer<Type>::Inner::innerFuncWorks()
21: {
23: }
24:
25: template <typename Type>
26: Outer<Type>::Inner<Type> Outer<Type>::Inner::innerFuncBroke()
27: {
28: }
29:
30: int main()
31: {
32: return 0;
33: }
34: //-------------------------------------------------
For example, G++ says:
Compiling: main.cpp
main.cpp:26: error: non-template type `Inner' used as a template
main.cpp:27: error: ISO C++ forbids declaration of `innerFuncBroke' with
no type
main.cpp:27: error: prototype for `int
Outer<Type>::Inner::innerFuncBroke()' does not match any in class
`Outer<Type>::Inner'
main.cpp:11: error: candidate is: Outer<Type>::Inner
Outer<Type>::Inner::innerFuncBroke()
main.cpp:27: error: template definition of non-template `int
Outer<Type>::Inner::innerFuncBroke()'
main.cpp: In member function `int Outer<Type>::Inner::innerFuncBroke()':
main.cpp:28: warning: no return statement in function returning non-void
Process terminated with status 1 (0 minutes, 0 seconds)
5 errors, 1 warnings
Essentially it appears to complain about the line where 'innerFuncBroke'
is defined. The only difference between this and 'innerFuncWorks' is the
return type, so this is presumably where the problem lies. I'm aware
that i'm returning no value and the compiler warns about that but it
doesn't appear to be the problem and i'm trying to keep the example simple.
Any ideas appriciated!
David