S
sw
Hi,
Is it possible to insert a class <vec> which has a vector<double>
member, into the vector<vec> veclist for e.g?
I've been getting compilation errors when trying to insert using the
vector method push_back() ->
c:\program files\microsoft visual studio\vc98\include\xutility(39) :
error C2679: binary '=' : no operator defined which takes a right-hand
operand of type 'const class vec' (or there is no acceptable
conversion)
c:\program files\microsoft visual studio\vc98\include\vector(170) : see
reference to function template instantiation 'void __cdecl
std::fill(class vec *,class vec *,const class vec &)' being compiled
c:\program files\microsoft visual studio\vc98\include\xmemory(34) :
error C2558: class 'vec' : no copy constructor available
c:\program files\microsoft visual studio\vc98\include\xmemory(66) : see
reference to function template instantiation 'void __cdecl
std::_Construct(class vec *,const class vec &)' being compiled
Error executing cl.exe.
I've already had an overloaded operator= for my vec class and i dont
really understand where the error lies in.
Here is my source code:
class <vec> header file
public:
vec();
vec(vec&);
vec(int, int); //dimension, vecid
vec(int, int, vector<double>); //dimension, vecid, coords
vec(int, int, vector<double>, vector<int>); //dimension, vecid,
coords, list of conected vecs
~vec();
void setvecid(int);
void setveccoord(vector<double>);
void setvecconnect(vector<int>);
void setvec(int, int, vector<double>, vector<int>);
void setvec(vec&);
int getdim();
int getvecid();
vector<double> getcoord(); //get the point coordinates
vector<int> getvecconnect(); //get the list of connected vecs
void addconnectvec(int); //add connected vec to the vecconnect list
void delconnectvec(int); //remove connected vec from list
bool searchvec(int); //search for vec in the vecconnect list
void sortvecconnect(); //sort the list in the
vec operator=(vec&);
In my main(), i declare a global variable:
vector<vec> globalvecs;
I get the compile error when i use the statement:
globalvecs.push_back(tmpvec);
inside the following block of code:
for(i = 0; i < numVec; i++)
{
vec tmpvec(dimension, i); //temp vec used to add to the global veclist
vector<double> tmpcoord; //vector to hold temp coordinates b4 setting
//tmpvec's coord
for(j = 0; j < dimension; j++)
{
read >> x; //where x is of type double
tmpcoord.push_back(x);
}
tmpvec.setveccoord(tmpcoord);
globalvecs.push_back(tmpvec);
}
Advance thanks for your replies!
Regards,
sw
Is it possible to insert a class <vec> which has a vector<double>
member, into the vector<vec> veclist for e.g?
I've been getting compilation errors when trying to insert using the
vector method push_back() ->
c:\program files\microsoft visual studio\vc98\include\xutility(39) :
error C2679: binary '=' : no operator defined which takes a right-hand
operand of type 'const class vec' (or there is no acceptable
conversion)
c:\program files\microsoft visual studio\vc98\include\vector(170) : see
reference to function template instantiation 'void __cdecl
std::fill(class vec *,class vec *,const class vec &)' being compiled
c:\program files\microsoft visual studio\vc98\include\xmemory(34) :
error C2558: class 'vec' : no copy constructor available
c:\program files\microsoft visual studio\vc98\include\xmemory(66) : see
reference to function template instantiation 'void __cdecl
std::_Construct(class vec *,const class vec &)' being compiled
Error executing cl.exe.
I've already had an overloaded operator= for my vec class and i dont
really understand where the error lies in.
Here is my source code:
class <vec> header file
public:
vec();
vec(vec&);
vec(int, int); //dimension, vecid
vec(int, int, vector<double>); //dimension, vecid, coords
vec(int, int, vector<double>, vector<int>); //dimension, vecid,
coords, list of conected vecs
~vec();
void setvecid(int);
void setveccoord(vector<double>);
void setvecconnect(vector<int>);
void setvec(int, int, vector<double>, vector<int>);
void setvec(vec&);
int getdim();
int getvecid();
vector<double> getcoord(); //get the point coordinates
vector<int> getvecconnect(); //get the list of connected vecs
void addconnectvec(int); //add connected vec to the vecconnect list
void delconnectvec(int); //remove connected vec from list
bool searchvec(int); //search for vec in the vecconnect list
void sortvecconnect(); //sort the list in the
vec operator=(vec&);
In my main(), i declare a global variable:
vector<vec> globalvecs;
I get the compile error when i use the statement:
globalvecs.push_back(tmpvec);
inside the following block of code:
for(i = 0; i < numVec; i++)
{
vec tmpvec(dimension, i); //temp vec used to add to the global veclist
vector<double> tmpcoord; //vector to hold temp coordinates b4 setting
//tmpvec's coord
for(j = 0; j < dimension; j++)
{
read >> x; //where x is of type double
tmpcoord.push_back(x);
}
tmpvec.setveccoord(tmpcoord);
globalvecs.push_back(tmpvec);
}
Advance thanks for your replies!
Regards,
sw