Hi all, I have a compilation error I can't seem to get through.
Here's what I do: I declare an object of class2, and I call its function "function2". This function, in turn, declares an object of class1 and calls its function "function1". Right now, this code gets a compilation error at that point ("function1" can't be properly called):
error: expected primary-expression before ‘)’ token
However, if I uncomment the useless "function1", then the code compiles. I find this confusing, because this is not the function being called, and should not affect at all.
#include <iostream>
using namespace std;
template<int parameter1>
class class1 {
public:
template < int parameter2 > void function1() {
cout << "We do useful things here" << endl;
}
};
template < int parameter3 >
class class2 {
public:
//template < char a, char b > bool function1() {
// cout << "Useless definition (?)" << endl;
//}
void function2() {
class1 < parameter3 > an_instance_of_class1;
an_instance_of_class1.function1 < 999 > ();
}
};
int main(int argc, char** argv) {
class2 < 99 > an_instance_of_class2;
an_instance_of_class2.function2();
}
Does anyone know what I'm missing? Thanks in advance.
Compiler version:
$ g++ --version
g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3