 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
arnuld Guest
|
Posted: Tue Oct 10, 2006 9:10 am Post subject: vector<string> gives error |
|
|
in C++ Primer 4/3 Lippman says in chapter 3, section 3.3.1:
vector<string> svec(10);
// 10 elements, each an empty string
here is the the code output & output from my Debian box running "gcc
3.3.5":
#include <iostream>
#include <vector>
#include <string>
int main() {
std::vector<string> svec(10);
// std::cout << v_str << std::endl;
return 0;
}
/* OUTPUT
unix@debian:~/programming/cpp$ g++ -ansi test-programme.cpp
test-programme.cpp: In function `int main()':
test-programme.cpp:6: error: `string' undeclared (first use this
function)
test-programme.cpp:6: error: (Each undeclared identifier is reported
only once
for each function it appears in.)
test-programme.cpp:6: error: template argument 1 is invalid
test-programme.cpp:6: error: template argument 2 is invalid
test-programme.cpp:6: error: ISO C++ forbids declaration of `svec' with
no type
unix@debian:~/programming/cpp$
*/
where is the trouble?
"arnuld" |
|
| Back to top |
|
 |
Sumit Rajan Guest
|
Posted: Tue Oct 10, 2006 9:10 am Post subject: Re: vector<string> gives error |
|
|
arnuld wrote:
| Quote: | in C++ Primer 4/3 Lippman says in chapter 3, section 3.3.1:
vector<string> svec(10);
// 10 elements, each an empty string
here is the the code output & output from my Debian box running "gcc
3.3.5":
#include <iostream
#include <vector
#include <string
int main() {
std::vector<string> svec(10);
|
std::vector<std::string> svec(10);
| Quote: |
// std::cout << v_str << std::endl;
return 0;
}
/* OUTPUT
unix@debian:~/programming/cpp$ g++ -ansi test-programme.cpp
test-programme.cpp: In function `int main()':
test-programme.cpp:6: error: `string' undeclared (first use this
function)
test-programme.cpp:6: error: (Each undeclared identifier is reported
only once
for each function it appears in.)
test-programme.cpp:6: error: template argument 1 is invalid
test-programme.cpp:6: error: template argument 2 is invalid
test-programme.cpp:6: error: ISO C++ forbids declaration of `svec' with
no type
|
Regards,
Sumit. |
|
| Back to top |
|
 |
arnuld Guest
|
Posted: Tue Oct 10, 2006 9:10 am Post subject: Re: vector<string> gives error |
|
|
Sumit Rajan wrote:
| Quote: | std::vector<string> svec(10);
std::vector<std::string> svec(10);
|
OK, i even tried "using std::vector" but still same error was reported.
it means, C++ Primer is wrong here.
anyway, what exactly "std::vector<string> svec;" &
"std::vector<std::string> svec;" say to the compiler? |
|
| Back to top |
|
 |
arnuld Guest
|
Posted: Wed Oct 11, 2006 9:11 am Post subject: Re: vector<string> gives error |
|
|
Noah Roberts wrote:
| Quote: | Nice, someone answers your question and you respond flippantly.
|
hey Noah, i did *not* ..mean ..that...., if you felt hurt then i
apologize. i wanted to say that i always check FAQs before posting my
problem as i must not waste other's preciuos time.
2nd, i posted that senetence without even looking at your name, i did
not know my friend "Noah" is here, i will change this habit now.
| Quote: | Oh well. Don't qualify your namespaces then. See how far it gets
yah. |
i admire "Modern C++ style", that is why i said check the FAQs & FAQs
say "do not use /using namespace std/ & i dont, even C++ Primer 4/e
does not use this.
thanks
"arnuld" -- www.arnuld.blogspot.com |
|
| Back to top |
|
 |
arnuld Guest
|
Posted: Wed Oct 11, 2006 9:11 am Post subject: Re: vector<string> gives error |
|
|
| Quote: | arnuld wrote:
2nd, i posted that senetence without even looking at your name, i did
not know my friend "Noah" is here, i will change this habit now.
|
OOPS, it was Martin, "sorry to Martin" :-)
thanks
> "arnuld" -- www.arnuld.blogspot.com |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|