gpt4 book ai didi

c++ - Turbo C++ 编译错误 "too many types in declaration"

转载 作者:太空狗 更新时间:2023-10-29 20:21:15 24 4
gpt4 key购买 nike

每当我编译这个程序时,我都会收到一条错误消息“第 13 行的 decleration 类型过多”。我没有看到任何可能的语法错误,但我仍然面临这个问题。

#include<iostream.h>
#include<conio.h>

class currency
{
private:
int rupee,paise;
int total;
public:
void getdata(int r,int p);
void display();

}
void currency::getdata(int r, int p){

rupee=r;
paise=p;
total=r*100+p;

}
void currency::display(){

cout<<rupee<<" Rupees"<<" and "<<paise<<"Paise"<<endl;
cout<<"Converted value="<<total;

}

int main(){

currency c;
c.getdata(5,25);
c.display();
getch();
return 0;

}

the error

最佳答案

需要有一个分号来结束类定义:

}  ;   // semicolon needed here.
void currency::getdata( ...

否则,编译器看起来像这样:

class blahblah {int etc, etc1; int etc2; } void currency::getdata (...

关于c++ - Turbo C++ 编译错误 "too many types in declaration",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44993373/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com