Hi
Here's a sintax in the constructor I've never seen, nor can I find an explanation:
class foo{
public:
foo(int a): b(a) {} //the constructor
private:
int b;
};
One could define foo(int a){ b=a; }. Why the different definition?
jmborr
If this is the case, then I'm in trouble because I generate multiple definitions of "foo" !
If I include "template.h" into files "one.cpp" and "two.cpp", and then I do "g++ one.o two.o", I will generate two definitions of "foo"...
Hi all,
I have a "template.h" file with a class template declaration, and I have "template.cpp" file with the definition of this class template.
It turns out that I have the following compilation error:
undefined reference to `vec<double>::foo()'
After googling, I found a...
Wow, who could have imagined this?
I was puzzled because I had also defined operators '+', '+=" and I had no complain with these ones.
Thank you for the huge help :)
jose
Hi all,
For some reason, my derived class does not inherit the operator '=' of my base class, which is a class template, when I compile with g++
//=========== base class
template<class T>
class vec{
public:
vec &operator=( vec ) ;
};
//=========== derived class
class vec_d : vec<double> {
}...
Hi all,
For some reason, my derived class does not inherit the operator '=' of my base class, which is a class template, when I compile with g++
//=========== base class
template<class T>
class vec{
public:
vec &operator=( vec ) ;
};
//=========== derived class
class vec_d : vec<double> {
}...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.