J
Jee
Hi,
Does Visual C++ support member function template? I have the
following code which can not get through VC6
compiler.
In header,
class myclass{
public:
template<class T>
static std::vector<T> getIntersection(std::vector<T>& ,
std::vector<T>& );
};
In Cpp file,
template<class T>
vector<T> myclass::getIntersection(vector<T>& v1, vector<T>&
v2){
vector<T> v;
vector<T>::iterator itr1;
if (v1.size() == 0){
return v;
}
......
return v;
}
This code passes SUN Forte compiler, but VC6 complains on this line,
if (v1.size() == 0){
as " error C2228: left of '.size' must have class/struct/union
type".
Do you know what's wrong here?
Thanks a lot.
Does Visual C++ support member function template? I have the
following code which can not get through VC6
compiler.
In header,
class myclass{
public:
template<class T>
static std::vector<T> getIntersection(std::vector<T>& ,
std::vector<T>& );
};
In Cpp file,
template<class T>
vector<T> myclass::getIntersection(vector<T>& v1, vector<T>&
v2){
vector<T> v;
vector<T>::iterator itr1;
if (v1.size() == 0){
return v;
}
......
return v;
}
This code passes SUN Forte compiler, but VC6 complains on this line,
if (v1.size() == 0){
as " error C2228: left of '.size' must have class/struct/union
type".
Do you know what's wrong here?
Thanks a lot.