本文介绍了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

推荐答案

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


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



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

11-03 06:19