|
|
Home » U++ Library support » U++ Core » How to do interation on Vector<String>
How to do interation on Vector<String> [message #10633] |
Fri, 20 July 2007 09:05  |
johnevans77
Messages: 38 Registered: July 2007
|
Member |
|
|
Dear all,
I followed tutorial on Container. Tried Vector<int> and worked. No problem.
Then i try to use Vector<String>. But, why this iteration code produce error message?
Vector<String> v2;
v2.Add("Str1");
v2.Add("Str2");
v2.Add("Str3");
for (Vector<String>::Iterator b = v.Begin(), e = v.End(); b != e; b++)
{
std::cout << "member " << " : " << *b << std::endl;
}
Please advise,
JE
|
|
|
|
|
Re: How to do interation on Vector<String> [message #10649 is a reply to message #10633] |
Fri, 20 July 2007 14:06   |
johnevans77
Messages: 38 Registered: July 2007
|
Member |
|
|
I have revised the code:
Vector<String> v2;
v2.Add("Str1");
v2.Add("Str2");
v2.Add("Str3");
for (Vector<String>::Iterator b = v2.Begin(), e = v2.End(); b != e; b++)
{
std::cout << "member " << " : " << *b << std::endl;
}
Compiles OK, but i have this strange output:
member : 0x80cafb0
member : 0x80cafb4
member : 0x80cafb8
Not, Str1, Str2, Str3 as expected.
UPDATED:
and now it behave strange. I compile it second time and many errors are produced. I am using Slackware 11, with GCC version 3.4.6.
Thanks
JE
[Updated on: Fri, 20 July 2007 14:20] Report message to a moderator
|
|
|
|
|
Re: How to do interation on Vector<String> [message #10654 is a reply to message #10653] |
Sat, 21 July 2007 12:25   |
 |
fudadmin
Messages: 1321 Registered: November 2005 Location: Kaunas, Lithuania
|
Ultimate Contributor Administrator |
|
|
johnevans77 wrote on Sat, 21 July 2007 06:48 |
...
1. But i usually using cout to output something to console.
|
Waste of time, very bad and stupid . Don't be insulted it's not at you. It's at a bit of a joke at the habit from pre-historic (pre-GUI) computers age...
Seriously, Why?
1. Is your apps interface mostly console?
2. The result is temporary:
3. you don't have "written" proof to show to other people 
4. can't compare to the other tests or runs.
5. can't have history.
6. have to wait while console opens
7. have to close the console window.
8. can't use that piece of code in real app.
9. ...
Strong advice:
1. do tests with your real small GUI's (or one for that purpose)
2. OR/AND learn and use ingenious U++ logging system!!!
3. AND/OR create a file, include it into the pr-aux package and do outputs to it (or use "always awake" editor like ADIE)
johnevans77 wrote on Sat, 21 July 2007 06:48 |
2. When i try to use std::cout, the compilation produced many errors.
|
Does any other console apps from examples work?
Have you setup your console package correctly (CONSOLE macro & CONSOLE flag) ?
johnevans77 wrote on Sat, 21 July 2007 06:48 |
3. I can forget std namespace if there is alternative.
|
I didn't say forget... but the alternative is very clear 
johnevans77 wrote on Sat, 21 July 2007 06:48 |
4.In this case, how to output the 'out' variable to console?
|
...
anyone with a clever answer?
P.S. to be continued (have to go..)
[Updated on: Sat, 21 July 2007 12:25] Report message to a moderator
|
|
|
Re: How to do interation on Vector<String> [message #10655 is a reply to message #10654] |
Sat, 21 July 2007 13:02   |
johnevans77
Messages: 38 Registered: July 2007
|
Member |
|
|
[quote title=fudadmin wrote on Sat, 21 July 2007 12:25]johnevans77 wrote on Sat, 21 July 2007 06:48 |
...
1. But i usually using cout to output something to console.
|
Quote: | Waste of time, very bad and stupid . Don't be insulted it's not at you. It's at a bit of a joke at the habit from pre-historic (pre-GUI) computers age...
|
No problem Hehe.
Quote: |
Seriously, Why?
1. Is your apps interface mostly console?
2. The result is temporary:
3. you don't have "written" proof to show to other people 
4. can't compare to the other tests or runs.
5. can't have history.
6. have to wait while console opens
7. have to close the console window.
8. can't use that piece of code in real app.
9. ...
|
Sometimes, i usually print variable's value in console, when running in debug mode. So, i need this feature When console is not open, should there is no problem. Just nothing is printed.
Quote: |
Strong advice:
1. do tests with your real small GUI's (or one for that purpose)
2. OR/AND learn and use ingenious U++ logging system!!!
3. AND/OR create a file, include it into the pr-aux package and do outputs to it (or use "always awake" editor like ADIE)
|
what is logging function/macro i can use?
Quote: |
johnevans77 wrote on Sat, 21 July 2007 06:48 |
2. When i try to use std::cout, the compilation produced many errors.
|
Does any other console apps from examples work?
Have you setup your console package correctly (CONSOLE macro & CONSOLE flag) ?
|
yes. All examples are working. Using vector<int>, std::cout also work. But not with vector<String>.
Quote: |
johnevans77 wrote on Sat, 21 July 2007 06:48 |
3. I can forget std namespace if there is alternative.
|
I didn't say forget... but the alternative is very clear 
|
can you tell me what are the alternatives? I am very new to ultimate++.
|
|
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Sat Apr 26 15:01:16 CEST 2025
Total time taken to generate the page: 0.01169 seconds
|
|
|