注册 登录
编程论坛 C++教室

不知道怎么修改

xizong 发布于 2007-02-01 18:09, 480 次点击
错误提示说:first use this function  请问我应该怎么修改好呢。当第一次使用函数的时候要注意些什么呢。!
5 回复
#2
monkeyzhen2007-02-01 20:39
是没有定义么?
#3
虫虫飞ya飞2007-02-06 16:31
你就这个提示不好说撒,把代码贴上看下.
#4
xizong2007-02-07 19:28

using namespace std;

int main(){
vector<string> names;
string const endinput("END");
cout << "type '" << endinput << "' when there are no more names.\n\n";
for( int finished(0); finished != 1; ){
cout << "type in the next name; ";
string fullname;
getline( cin, fullname );
if( endinput == fullname )
finished = 1;
else
names.push_back( fullname ) ;
}
sort( names.begin(), names.end());
ofstresam outfile("name.txt");
for( int i(0); i != names.size(); ++i ){
cout << names[i] << '\n';
outfile << names[i] << '\n';
}
}

#5
lehmann2007-03-11 22:45

实在看不懂你的错误是什么意思
我就改了一下
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <fstream>

using namespace std;

int main(){
vector<string> names;
const string endinput("END");
cout << "type '" << endinput << "' when there are no more names.\n\n";
for( int finished(0); finished != 1; ){
cout << "type in the next name; ";
string fullname;
getline( cin, fullname );
if( endinput == fullname )
finished = 1;
else
names.push_back( fullname ) ;
}
sort( names.begin(), names.end());
ofstream outfile("name.txt");
for( int i(0); i != names.size(); ++i ){
cout << names[i] << '\n';
outfile << names[i] << '\n';
}
}
这里面可能还有问题,不知道改的对不对

#6
dick_zq0072007-03-13 16:23
没有定义头文件吧你~~
1