hello!

i've just tried out lists in c++, but they're giving me some kind of problem. it has something to do with iterators but i'm pretty sure i'm using them the right way. anyway, here is the code:

#include <list>
#include <iostream>

int main(int argc, char* argv[])
{
	std::list<int* > numbers;
	int a = 5;
	int b = 4;
	int c = 12;
	
	numbers.push_back(&a);
	numbers.push_back(&b);
	numbers.push_back(&c);

	std::list<int* >::iterator cit = numbers.end();

	//delete *cit;

	std::list<int* >::iterator it;

	for (it = numbers.begin(); it != numbers.end(); it++)
		std::cout << *it << std::endl;

	system("pause");
	return 0;
}

and the error message:

1> Main.cpp
1>Main.obj : error LNK2019: unresolved external symbol __imp___CrtDbgReportW referenced in function "public: int * const & __thiscall std::_List_const_iterator<class std::_List_val<int *,class std::allocator<int *> > >::operator*(void)const " (??D?$_List_const_iterator@V?$_List_val@PAHV?$allocator@PAH@std@@@std@@@std@@QBEABQAHXZ)
1>D:\Projects\C++\Projects\Blian\Debug\Blian.exe : fatal error LNK1120: 1 unresolved externals


i'm using vsc++ 2010 btw.

Recommended Answers

All 2 Replies

I dislike vsc++ but there we go. I just compiled it on MinGW with no problems what so ever, i was presented with a list of the address that your data was stored at.

if you want the data to be printed you will need to use **it not just *it.

Chris

turned out i just had to change runtime library from multi-threaded dll to multi-threaded debug dll.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.