功能应该有一个原型 [英] function should have a prototype
问题描述
大家好,
我是C ++的新手...我试着编译以下程序...
#include< ; iostream.h>
#include< conio.h>
#include< string>
#include< stdio.h>
int main(){
String mystr;
cout<< 你的名字是什么?;
getline(cin,mystr);
cout<< 我的名字是: << mystr;
cout<< 你最喜欢的球队是什么?;
getline(cin,mystr);
cout<< 我最喜欢的球队是 << mystr;
getch();
返回0;
}
但我得到了错误''函数getline应该有一个原型''...我除了这个之外还得到其他错误...但我想如果我可以添加相关的#include ......我可以修复这个错误..任何人都可以告诉我它是什么''getline''函数... thnk in advnce ...
大家好,
我是C ++的新手......我试着编译以下程序......
>
#include< iostream.h>
#include< conio.h>
#include< string>
#include< ; stdio.h>
int main(){
String mystr;
cout<< 你的名字是什么?;
getline(cin,mystr);
cout<< 我的名字是: << mystr;
cout<< 你最喜欢的球队是什么?;
getline(cin,mystr);
cout<< 我最喜欢的球队是 << mystr;
getch();
返回0;
}
但我得到了错误''函数getline应该有一个原型''...我除了这个之外还得到其他错误...但我想如果我可以添加相关的#include ......我可以解决这个错误..任何人都可以告诉我它是什么''getline''功能... thnk in advnce ...
它''您缺少的命名空间。您可以使用std :: getline或在包含以下内容后添加此行:
展开 | 选择 | 换行 | 行号
< blockquote>
大家好,
我是C ++的新手......我试着编译以下程序...
#include< iostream.h>
#include< conio.h>
#include< string> ;
#include< stdio.h>
int main(){
String mystr;
cout<< 你的名字是什么?;
getline(cin,mystr);
cout<< 我的名字是: << mystr;
cout<< 你最喜欢的球队是什么?;
getline(cin,mystr);
cout<< 我最喜欢的球队是 << mystr;
getch();
返回0;
}
但我得到了错误''函数getline应该有一个原型''...我除了这个之外还得到其他错误...但我想如果我可以添加相关的#include ......我可以解决这个错误..任何人都可以告诉我它是什么''getline''功能... thnk in advnce ...
我想要添加到上面的回复。在包含标准c ++库时,您应该避免使用.h。所以最好使用
展开 | 选择 | Wrap | 行号
即使他没有使用名称空间,他也很容易做到:
展开 | 选择 | Wrap | 行号
Hi all,
I am new to C++...I tried to compile the following program...
#include<iostream.h>
#include<conio.h>
#include<string>
#include<stdio.h>
int main() {
String mystr;
cout << "What is your name?";
getline(cin,mystr);
cout << "my name is:" << mystr;
cout << "What is your favourite team?";
getline(cin, mystr);
cout << "My favourite team is " << mystr;
getch();
return 0;
}
but i am getting the error ''function getline should have a prototype''...I am getting other errors as well apart from this ...but i think if i can add the relevant "#include..." i can fix this error..can anyone please tell me what is it for ''getline'' function...thnk in advnce...解决方案Hi all,
I am new to C++...I tried to compile the following program...
#include<iostream.h>
#include<conio.h>
#include<string>
#include<stdio.h>
int main() {
String mystr;
cout << "What is your name?";
getline(cin,mystr);
cout << "my name is:" << mystr;
cout << "What is your favourite team?";
getline(cin, mystr);
cout << "My favourite team is " << mystr;
getch();
return 0;
}
but i am getting the error ''function getline should have a prototype''...I am getting other errors as well apart from this ...but i think if i can add the relevant "#include..." i can fix this error..can anyone please tell me what is it for ''getline'' function...thnk in advnce...It''s namespace that you are missing.You can use std::getline or add this line after includes:
Expand|Select|Wrap|Line Numbers
Hi all,
I am new to C++...I tried to compile the following program...
#include<iostream.h>
#include<conio.h>
#include<string>
#include<stdio.h>
int main() {
String mystr;
cout << "What is your name?";
getline(cin,mystr);
cout << "my name is:" << mystr;
cout << "What is your favourite team?";
getline(cin, mystr);
cout << "My favourite team is " << mystr;
getch();
return 0;
}
but i am getting the error ''function getline should have a prototype''...I am getting other errors as well apart from this ...but i think if i can add the relevant "#include..." i can fix this error..can anyone please tell me what is it for ''getline'' function...thnk in advnce...I would like to add to the above reply. You should refrain from using the .h when including standard c++ libraries. So preferably use
Expand|Select|Wrap|Line Numbers
Well even if he didn''t use the namespace he could easily do:
Expand|Select|Wrap|Line Numbers
这篇关于功能应该有一个原型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文登录 关闭
扫码关注1秒登录发送“验证码”获取 | 15天全站免登陆