为了账号安全,请及时绑定邮箱和手机立即绑定

linux 用g++编译c++代码的问题?

linux 用g++编译c++代码的问题?

PHP
一只斗牛犬 2019-03-15 10:07:27
:~/c13.03/more$ g++ -o t t.cppt.cpp:12:0: 警告: “CLOCKS_PER_SEC”重定义 [默认启用]/usr/include/x86_64-linux-gnu/bits/time.h:49:0: 附注: 这是先前定义的位置t.cpp: 在函数‘int main(int, const char**)’中:t.cpp:32:111: 错误: 对‘std::basic_ofstream<char>::open(std::basic_string<char>, std::_Ios_Openmode)’的调用没有匹配的函数t.cpp:32:111: 附注: 备选是:/usr/include/c++/4.6/fstream:702:7: 附注: void std::basic_ofstream<_CharT, _Traits>::open(const char*, std::ios_base::openmode) [with _CharT = char, _Traits = std::char_traits<char>, std::ios_base::openmode = std::_Ios_Openmode]/usr/include/c++/4.6/fstream:702:7: 附注: no known conversion for argument 1 from ‘std::basic_string<char>’ to ‘const char*’我的源代码出错的open函数:fout.open("/home/wangwenyu/c13.03/more"+filename+".in",std::ofstream::out | std::ofstream::app);fout<<"title typical input stream"<<endl;
查看完整描述

3 回答

?
ibeautiful

TA贡献1993条经验 获得超5个赞

#include<iostream>
#include<vector>
using std::cout;
using std::endl;
using std::vector;

int main()
{
vector<int> container;
for(int i=1;i<=4;i++)
container.push_back(i);
cout<<"here is what is in the container:\n";
vector<int>::iterator p;
for(p=container.begin();p!=container.end();p++)
cout<<*p<<" ";
cout<<endl;

cout<<"setting entries to 0:\n";
for(p=container.begin();p!=container.end();p++)
*p=0;

cout<<"contanier now contains:\n";
for(p=container.begin();p!=container.end();p++)
cout<<*p<<" ";
cout<<endl;
return 0;
}



查看完整回答
反对 回复 2019-03-30
  • 3 回答
  • 0 关注
  • 698 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信