I'm using VC++ .Net to do a simlple program. I tried to use <vector>,
<list> in the program, and I simply put the folowing lines
"
#include <list>
#include <vector>
#include <string>
using namespace std;
.....
vector <int> list;

"
in the head part of my file "simple.h". But it gives compilation error
when I try to compile it in "Debug" mode, but it's ok in the "Release"
mode.

I tries several ways to solve it, but I always got compilation error
related to files: "xdebug", "xmemory"...

Does someone know what I should do to make it working in "Debug" mode?

Thanks very much

Re: help on using <list> <vector> in a simple VC program by Igor

Igor
Tue Apr 11 15:20:23 CDT 2006

kuiyuli@gmail.com wrote:
> I'm using VC++ .Net to do a simlple program. I tried to use <vector>,
> <list> in the program, and I simply put the folowing lines
> "
> #include <list>
> #include <vector>
> #include <string>
> using namespace std;
> .....
> vector <int> list;
>
> in the head part of my file "simple.h".

First, you should not define variables in the header file, otherwise
you'll likely get linker errors since every source file that includes
your header gets a copy of the variable. Do it this way:

// in .h file
extern vector<int> myList;

// in exactly one .cpp file
vector<int> myList;


Second, it's probably not a terribly good idea to give a variable the
same name as a class (I'm talking about 'list'). I don't think it should
produce an error, but it's likely to create confusion.

> But it gives compilation error
> when I try to compile it in "Debug" mode, but it's ok in the "Release"
> mode.

Quote the exact error text, and show the line of code it refers to. I
seem to have misplaced my crystal ball.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925



Re: help on using <list> <vector> in a simple VC program by Arnaud

Arnaud
Tue Apr 11 15:46:50 CDT 2006

Igor Tandetnik wrote:
> Quote the exact error text, and show the line of code it refers to. I
> seem to have misplaced my crystal ball.

Regular posters to the newsgroup should syndicate to get a discount price on
crystal balls ;-)

Arnaud
MVP - VC



Re: help on using <list> <vector> in a simple VC program by kuiyuli

kuiyuli
Tue Apr 11 17:40:28 CDT 2006

Thank you Igor, I've found the reason that causes the error. Actually,
I put this header file to the wrong place in my "...View.cpp" file,
which causes the compilation error in "Debug" mode.

Thanks very much.