I'm using Visual Studio 2005, but i don't think that's (primarily)
where I've gone wrong.
I was experimenting, trying, by the way, to move into writing my own
iterator so that I can learn, ultimately, to write templates:
std::map< int, char [12] cm;
char str0[12] = {'f','i','r','s','t',' ','t','e','x','t','\0'};
cm[0] = str0;
The compiler says about that assignment,
left operand must be l-value
What does this mean, what's happened here?
It compiles without error when the value arg in the map is instead a
char or a char *.
std::map< int, char *cm;
Thanks for your help and knowledge.
Harold 9 1730
Heck wrote:
I'm using Visual Studio 2005, but i don't think that's (primarily)
where I've gone wrong.
I was experimenting, trying, by the way, to move into writing my own
iterator so that I can learn, ultimately, to write templates:
std::map< int, char [12] cm;
char str0[12] = {'f','i','r','s','t',' ','t','e','x','t','\0'};
cm[0] = str0;
The compiler says about that assignment,
left operand must be l-value
What does this mean, what's happened here?
It compiles without error when the value arg in the map is instead a
char or a char *.
std::map< int, char *cm;
Arrays are not assignable.
On 2007-11-16 00:12, Heck wrote:
I'm using Visual Studio 2005, but i don't think that's (primarily)
where I've gone wrong.
I was experimenting, trying, by the way, to move into writing my own
iterator so that I can learn, ultimately, to write templates:
std::map< int, char [12] cm;
char str0[12] = {'f','i','r','s','t',' ','t','e','x','t','\0'};
cm[0] = str0;
The compiler says about that assignment,
left operand must be l-value
What does this mean, what's happened here?
It compiles without error when the value arg in the map is instead a
char or a char *.
std::map< int, char *cm;
You can not store an array in a map (or any other collection for that
matter).
--
Erik Wikström
Heck wrote:
char str0[12] = {'f','i','r','s','t',' ','t','e','x','t','\0'};
Btw, you can save typing by simply writing:
char str0[12] = "first text";
Erik Wikström wrote:
You can not store an array in a map (or any other collection for that
matter).
Sorry, I don't understand what you mean by collection. Could you please
expand on that?
TIA
LR
LR wrote:
Erik Wikström wrote:
>You can not store an array in a map (or any other collection for that matter).
Sorry, I don't understand what you mean by collection. Could you
please expand on that?
Erik will hopefully give his POV, but AFAICT, Erik meant any standard
container by "any other collection".
Arrays do not satisfy the requirements for the contained items. The
main two are Assignable and Copy-constructible. Arrays are neither.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
On Nov 15, 11:41 pm, Erik Wikström <Erik-wikst...@telia.comwrote:
On 2007-11-16 00:12, Heck wrote:
I'm using Visual Studio 2005, but i don't think that's (primarily)
where I've gone wrong.
I was experimenting, trying, by the way, to move into writing my own
iterator so that I can learn, ultimately, to write templates:
std::map< int, char [12] cm;
char str0[12] = {'f','i','r','s','t',' ','t','e','x','t','\0'};
cm[0] = str0;
The compiler says about that assignment,
left operand must be l-value
What does this mean, what's happened here?
It compiles without error when the value arg in the map is instead a
char or a char *.
std::map< int, char *cm;
You can not store an array in a map (or any other collection for that
matter).
--
Erik Wikström
Wrap your array in a class and define the assignment operator
Jeff http://theschmitzer.blogspot.com
On 2007-11-16 16:58, LR wrote:
Erik Wikström wrote:
>You can not store an array in a map (or any other collection for that matter).
Sorry, I don't understand what you mean by collection. Could you please
expand on that?
Sorry about that, I have been programming to much VBA (ugh!) lately.
Just like Victor guessed I meant a standard container.
--
Erik Wikström
Erik Wikström!
>On 2007-11-16 00:12, Heck wrote:
>I'm using Visual Studio 2005, but i don't think that's (primarily) where I've gone wrong.
I was experimenting, trying, by the way, to move into writing my own iterator so that I can learn, ultimately, to write templates: std::map< int, char [12] cm; char str0[12] = {'f','i','r','s','t',' ','t','e','x','t','\0'};
cm[0] = str0;
The compiler says about that assignment, left operand must be l-value
What does this mean, what's happened here?
It compiles without error when the value arg in the map is instead a char or a char *. std::map< int, char *cm;
You can not store an array in a map (or any other collection for that matter).
OK, thanks (and thank you all). Is your answer consistent with the
compiler telling me the map element, in this case, cm[0], is not an
l-value? It is an l-value, isn't it? It's the array that's not an
r-value, right? je***************@gmail.com!
>On Nov 15, 11:41 pm, Erik Wikström <Erik-wikst...@telia.comwrote:
>On 2007-11-16 00:12, Heck wrote:
I'm using Visual Studio 2005, but i don't think that's (primarily)
where I've gone wrong.
I was experimenting, trying, by the way, to move into writing my own
iterator so that I can learn, ultimately, to write templates:
std::map< int, char [12] cm;
char str0[12] = {'f','i','r','s','t',' ','t','e','x','t','\0'};
cm[0] = str0;
The compiler says about that assignment,
left operand must be l-value
What does this mean, what's happened here?
It compiles without error when the value arg in the map is instead a
char or a char *.
std::map< int, char *cm;
You can not store an array in a map (or any other collection for that matter).
-- Erik Wikström
Wrap your array in a class and define the assignment operator
I'm getting to that, yes. Thanks very much. This discussion thread is closed Replies have been disabled for this discussion. Similar topics
24 posts
views
Thread by Duane Hebert |
last post: by
|
44 posts
views
Thread by jmoy |
last post: by
|
14 posts
views
Thread by Flzw |
last post: by
|
19 posts
views
Thread by Erik Wikström |
last post: by
|
3 posts
views
Thread by Dan Trowbridge |
last post: by
|
13 posts
views
Thread by Peteroid |
last post: by
|
20 posts
views
Thread by Dilip |
last post: by
|
5 posts
views
Thread by Jim Langston |
last post: by
|
3 posts
views
Thread by digz |
last post: by
| | | | | | | | | | |