功能应该有一个原型

编程入门 行业动态 更新时间:2024-10-24 06:29:17
本文介绍了功能应该有一个原型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我是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或在包含以下内容后添加此行:

展开 | 选择 | 换行 | 行号

大家好, 我是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

更多推荐

功能应该有一个原型

本文发布于:2023-11-16 06:22:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1601775.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:原型   有一个   功能

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!