#include <iostream.h>
#include <windows.h>
#include <vector>
using namespace std;
class Fff
{
public:
int y;
int z;
};
class space
{
public:
vector< Fff > varden;
space(void)
{
varden.resize(1);
}
};
//vector< Fff * > space::varden(0);
//vector < fffff > space::varden(0);
void main ()
{
space sp;
Fff fg;
//sp.varden[0] = fg;
int g;
cin>>g;
}
This code gives me these errors:
C:\Program Files\DevStudio\MyProjects\vectors\test.cpp(40) : warning C4101: ''fg'' : unreferenced local variable
C:\Program Files\DevStudio\VC\INCLUDE\xutility(45) : error C2784: ''bool __cdecl std::operator <(const class std::reverse_iterator<`template-parameter-1'',`template-parameter-2'',`template-parameter-3'',`template-parameter-4'',`template-parameter-5''> &,c
onst class std::reverse_iterator<`template-parameter-1'',`template-parameter-2'',`template-parameter-3'',`template-parameter-4'',`template-parameter-5''> &)'' : could not deduce template argument for ''const class std::reverse_iterator<`template-parameter-
1'',`template-parameter-2'',`template-parameter-3'',`template-parameter-4'',`template-parameter-5''> &'' from ''const class Fff''
C:\Program Files\DevStudio\VC\INCLUDE\xutility(45) : error C2784: ''bool __cdecl std::operator <(const struct std::pair<`template-parameter-1'',`template-parameter-2''> &,const struct std::pair<`template-parameter-1'',`template-parameter-2''> &)'' : could
not deduce template argument for ''const struct std::pair<`template-parameter-1'',`template-parameter-2''> &'' from ''const class Fff''
C:\Program Files\DevStudio\VC\INCLUDE\xutility(45) : error C2676: binary ''<'' : ''const class Fff'' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\Program Files\DevStudio\VC\INCLUDE\xutility(47) : error C2784: ''bool __cdecl std::operator <(const class std::reverse_iterator<`template-parameter-1'',`template-parameter-2'',`template-parameter-3'',`template-parameter-4'',`template-parameter-5''> &,c
onst class std::reverse_iterator<`template-parameter-1'',`template-parameter-2'',`template-parameter-3'',`template-parameter-4'',`template-parameter-5''> &)'' : could not deduce template argument for ''const class std::reverse_iterator<`template-parameter-
1'',`template-parameter-2'',`template-parameter-3'',`template-parameter-4'',`template-parameter-5''> &'' from ''const class Fff''
C:\Program Files\DevStudio\VC\INCLUDE\xutility(47) : error C2784: ''bool __cdecl std::operator <(const struct std::pair<`template-parameter-1'',`template-parameter-2''> &,const struct std::pair<`template-parameter-1'',`template-parameter-2''> &)'' : could
not deduce template argument for ''const struct std::pair<`template-parameter-1'',`template-parameter-2''> &'' from ''const class Fff''
C:\Program Files\DevStudio\VC\INCLUDE\xutility(47) : error C2676: binary ''<'' : ''const class Fff'' does not define this operator or a conversion to a type acceptable to the predefined operator
Error executing cl.exe.
test.obj - 6 error(s), 1 warning(s)
What is wrong with this code? (vectors)
I have been trying to make vectors work with classes a long time now but I can''t make it work.
Here''s the code (test application):
A quick glance at your code:
most of the stl container templates require that you have a copy constructor, an assignment operator. I am not sure, but if you use the find template , not using a pred, you will need to have the comparison operators defined as well. ==, !=, these 2 at least.
Try adding a copy constructor and an assignment operator overload. See what happens then.
Alek
most of the stl container templates require that you have a copy constructor, an assignment operator. I am not sure, but if you use the find template , not using a pred, you will need to have the comparison operators defined as well. ==, !=, these 2 at least.
Try adding a copy constructor and an assignment operator overload. See what happens then.
Alek
Hmmm... This code compiles fine for me using VC 6.0 SP 3, so I don''t think it''s your code that''s the problem. It''s either a bug in your version of VC or a busted VC install. I''d recommend just trying some very simple code to see if ANY stl stuff works. Eg:
You could also try installing the newest SP for VC, or porting the SGI implementaion of stl (http://www.sgi.com/Technology/STL/download.html).
...Syzygy
void main (){ vector v; v.push_back(1);}
You could also try installing the newest SP for VC, or porting the SGI implementaion of stl (http://www.sgi.com/Technology/STL/download.html).
...Syzygy
That makes sense since the error isn't in my fily but in the MSVC files.
The problem is that I have MSVC 5.
Edited by - Mr Cucumber on July 17, 2000 1:55:29 PM
The problem is that I have MSVC 5.
Edited by - Mr Cucumber on July 17, 2000 1:55:29 PM
Well VC5 is not your problem, I just copy & pasted the code into VC5 and it compiled fine (other than that warning about not referencing a local variable, but thats not important in this case). As was pointed out above, you probably have a broken install. Try reinstalling VC5, and getting Service Pack 3 for DevStudio (can be found on Microsoft''s web site), and while your at it, go ahead and download the newest Platform SDK for Windows.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement