Search code examples
c++typesturbo-c++

Turbo C++ compile error "too many types in declaration"


whenever I compile this program, I get an error saying "Too many types in decleration on line 13". I do not see any possible syntax errors but still I am facing this issue.

#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


Solution

  • There needs to be a semicolon to terminate the class definition:

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

    Otherwise, it looks like this to the compiler:

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