By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,605 Members | 1,400 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,605 IT Pros & Developers. It's quick & easy.

access <list> with array

P: 3
Hi there 1

This part has no problem with compilation, but further I don't know how to access "item". Pls help ! Thx !

{
typedef double tab[3];
std::list<tab> tbBigList;
tab tb;
tb[0]=0.1;
tb[1]=0.2;
tb[2]=0.3;
tbBigList.push_over(tb);
std::list<tab>::iterator item;
item=tbBigList.begin();

// how do I access item[0], item[1], item[2] ?

}
Nov 9 '06 #1
Share this Question
Share on Google+
4 Replies


Banfa
Expert Mod 5K+
P: 8,916
Item will be a tab * so I think

(*item)[0]
(*item)[1]
(*item)[2]
Nov 9 '06 #2

P: 3
Item will be a tab * so I think

(*item)[0]
(*item)[1]
(*item)[2]
Thanks for answer!
it's not working,
but I found same mistakes of mine :

1. tbBigList.push_over(tb); is wrong
tbBigList.push_back(tb); is OK

2. even so, while compiling "tbBigList.push_back(tb)" I'm sent to _construct.h and can't finishing compiling. I think something is wrong with initialisation, but I'm the rookie ..

thanx again
Nov 10 '06 #3

Banfa
Expert Mod 5K+
P: 8,916
You will need top post the compile errors you are getting
Nov 10 '06 #4

P: 3
You will need top post the compile errors you are getting
Hi again!

You're right! I should done this from beginning !

1.error message:
(C++ Error) _construct.h(85): E2243 Array allocated using 'new' may not have an initializer

2. line in _construct.h underlined (marked with ------->>>>>):

template <class _T1, class _T2>
inline void _Construct(_T1* __p, const _T2& __value) {
# ifdef _STLP_DEBUG_UNINITIALIZED
memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1));
# endif
------->>>>> _STLP_PLACEMENT_NEW (__p) _T1(__value);
}

In case it's useful: I'm using Borland C++ platform.

All best
Nov 10 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.