C ++中的错误 [英] error in C++

查看:49
本文介绍了C ++中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,进行一些C ++培训时遇到问题.当我编译我的代码时,我得到一个错误的说法; 缺少函数标头(旧式正式列表),而另一个说空应该以;" 开头,我真的找不到出路,请有人帮我?这是我的下面的代码



hello everybody , am having a problem when doing some trainning C++. When i compile my code i get an error saying ; Missing function header(old style formal list ) and another saying void should be preceded by ";", i real can''t find a way out please can somebody help me ? this is my code below



//this program demonstrates the use of function 

#include <iostream>


using namespace std;

// function prototype
void displayLine ()

void main ();
{
	// Declare and initialized a Variable 
	float numberInput = 0,0;
	float numberSquared=0,0;
	float numberHalved =0,0;

	//emter input Item
	cout <<" Enter a number : ";
	cin >> numberInput ;

	//calculate the square of the number and the number halved 

	numberSquared = numberInput * numberInput ;
	numberHalved =  numberInput / 2 ;

	// Display the output items
	displayLine ();
	cout <<"Result of Calcutations : " << endl ;
	cout <<"Square of the Number : " << numberSquared << endl;
	cout <<"Half of the Number : " << numberHalved << endl;
	system("pause");
}  //end of main function 

//********* Programmer - defined function definitions *********

void displayLine ();
{
	cout <<" --------------------------- : " << endl1;
} //end of displaying line function

推荐答案

删除;"在:

Delete the ";" in:

void main ();
{







and

void displayLine ();
{



并将其插入:



and insert it in:

// function prototype
void displayLine ();



您也应该在程序的最后一个"endl"中删除"1"



You should delete the "1" in the last "endl" of your program as well


请尝试一下:):

Please try it :) :

void displayLine();
 
void main()
{
...
}
 
void displayLine()
{
...
}


我将为 Nelek Eugen Podsypalnikov 的正确响应添加一个点,其中涵盖了错误消息,你正在得到.它应该是int main()而不是void main().作为参考,请参见此处. [
I''ll add one point to the correct responses by Nelek and Eugen Podsypalnikov that covered the error messages that you were getting. It should be int main() rather than void main(). For reference see here.[^]


这篇关于C ++中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆