矢量<串GT;给出错误 [英] vector<string> gives error
问题描述
in C ++ Primer 4/3 Lippman在第3章第3.3.1节中说:
vector< stringsvec(10);
// 10元素,每个空字符串
这里是代码输出&从我的Debian框中输出gcc
3.3.5:
#include< iostream>
#include < vector>
#include< string>
int main(){
std :: vector< stringsvec( 10);
// std :: cout<< v_str<< std :: endl;
返回0;
}
/ *输出
unix @ debian:〜/ programming / cpp $ g ++ -ansi test-programme.cpp
test-programme.cpp:在函数`int main()''中:
test-programme.cpp:6:错误:`string''未声明(首先使用此
函数)
test-programme.cpp:6 :错误:(每个未声明的标识符报告
只显示一次
。)
test-programme.cpp:6 :错误:模板参数1无效
test-programme.cpp:6:错误:模板参数2无效
test-programme.cpp:6:错误:ISO C ++禁止使用
声明`svec''没有类型
unix @ debian:〜/ programming / cpp $
* /
哪里有麻烦?
" arnuld"
in C++ Primer 4/3 Lippman says in chapter 3, section 3.3.1:
vector<stringsvec(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<stringsvec(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"
推荐答案
g ++ -ansi test-programme.cpp
test-programme.cpp:在函数中`int main()'':
test-programme.cpp:6:错误:`string''未声明(首先使用这个
函数)
test-programme.cpp:6:错误:(每个未声明的标识符报告
只出现一次
出现的每个函数。)
test-programme.cpp:6:错误:模板参数1无效
test-programme.cpp:6:错误:模板参数2无效
test -programme.cpp:6:错误:ISO C ++禁止声明`svec''
没有类型
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
* /
哪里有麻烦?
" arnuld"
*/
where is the trouble?
"arnuld"
arnuld写道:
arnuld wrote:
in C ++ Primer 4/3 Lippman说在第3章第3.3.1节:
vector< stringsvec(10);
// 10个元素,每个元素都是一个空字符串
这里是代码输出&从我的Debian框中输出gcc
3.3.5:
#include< iostream>
#include < vector>
#include< string>
int main(){
std :: vector< stringsvec( 10);
in C++ Primer 4/3 Lippman says in chapter 3, section 3.3.1:
vector<stringsvec(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<stringsvec(10);
std :: vector< std :: stringsvec(10);
std::vector<std::stringsvec(10);
>
// std :: cout<< v_str<< std :: endl;
返回0;
}
/ * OUTPUT
unix @ debian:〜/ programming / cpp
>
// std::cout << v_str << std::endl;
return 0;
}
/* OUTPUT
unix@debian:~/programming/cpp
这篇关于矢量<串GT;给出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!