$ cat -n cons.cpp
1 #include <iostream>
2
3 using namespace std;
4
5 int return1() {
6 return 1;
7 }
8
9 int main() {
10 cout<< return1.m_one << endl;
11 return 0;
12 }
$ g++ cons.cpp
cons.cpp: In function 'int main()':
cons.cpp:10: error: request for member 'm_one' in 'return1',
which is of non-class type 'int ()()'
$
Maybe this is compiler specific, but is there some significance / meaning of the extra pair of brackets in int ()() as reported by g++ above?
The idea of this syntax is this:
inton the left side means My return type isintHence if the function had been declared as
the error message would talk about
int ()(int).But the way the function type is represented indeed depends on the compiler as well as the version. E.g. GCC 4.5.1 which I just tried simply said
int()as you suggested as more intuitive.