P
PengYu.UT
Hi,
It seems that the line with "//no error" and "//error" are the same.
However, the second one give an error.
I'm using g++-3.3.
The error message was:
g++-3.3 -g -c -o main.o main.cc
main.cc: In function `int main(int, char**)':
main.cc:85: error: parse error before `,' token
make: *** [main.o] Error 1
Best wishes,
Peng
template <typename __Tp>
class A{
public:
A(){};
~A(){};
virtual void fun() = 0;
};
template <typename __Tp>
class A1 : public A<__Tp>{
public:
A1(){};
~A1(){};
virtual void fun() {};
};
template <typename __Tp>
class B{
public:
B(__Tp x, __Tp y, __Tp z){};
~B(){};
virtual void fun() = 0;
};
template <typename __Tp>
class B1 : public B<__Tp>{
public:
B1(__Tp x, __Tp y): B<__Tp>(x, x, y){};
~B1(){};
virtual void fun() {};
};
template <typename __Tp>
class D{
public:
D(const A<__Tp> &A_inst, const B<__Tp> &B_inst){};
~D(){};
};
int main(int argc, char *argv[])
{
const double x = 0;
A1<double> A1_inst;
B1<double> B1_inst(x, x);
//D<double> D_inst(A1_inst, B1_inst);//no error
D<double> D_inst(A1<double>, B1<double>(x,x));//error
}
It seems that the line with "//no error" and "//error" are the same.
However, the second one give an error.
I'm using g++-3.3.
The error message was:
g++-3.3 -g -c -o main.o main.cc
main.cc: In function `int main(int, char**)':
main.cc:85: error: parse error before `,' token
make: *** [main.o] Error 1
Best wishes,
Peng
template <typename __Tp>
class A{
public:
A(){};
~A(){};
virtual void fun() = 0;
};
template <typename __Tp>
class A1 : public A<__Tp>{
public:
A1(){};
~A1(){};
virtual void fun() {};
};
template <typename __Tp>
class B{
public:
B(__Tp x, __Tp y, __Tp z){};
~B(){};
virtual void fun() = 0;
};
template <typename __Tp>
class B1 : public B<__Tp>{
public:
B1(__Tp x, __Tp y): B<__Tp>(x, x, y){};
~B1(){};
virtual void fun() {};
};
template <typename __Tp>
class D{
public:
D(const A<__Tp> &A_inst, const B<__Tp> &B_inst){};
~D(){};
};
int main(int argc, char *argv[])
{
const double x = 0;
A1<double> A1_inst;
B1<double> B1_inst(x, x);
//D<double> D_inst(A1_inst, B1_inst);//no error
D<double> D_inst(A1<double>, B1<double>(x,x));//error
}