Please help me run this program, i forgot the output of this..

#include<iostream>

#include<cmath>

using namespace std;

class SumTwoNumbers
{

int nx,ny,sum,suma,sumtn;

public:
int GetFirstNumber();
int GetSecondNumber();
int GetSum(int,int);

void Display(int,int);

}stn;

int SumTwoNumbers::GetFirstNumber()

sum=nx+ny; //here is where the errors i wrote below points! i dont know why

return(sum);

int SumTwoNumbers::GetSecondNumber()

suma=nx+ny;

return(suma);

int SumTwoNumbers::GetSum()

sumtn=sum+suma;

return(sumtn);

int SumTwoNumbers::Display()

stn.GetSum(sum,suma);


int main()
{
int a,b,c,d;
SumTwoNumbers stn;

cout<<"Enter two Numbers: ";
cin>>a>>b;

cout<<"Enter two Number: ";
cin>>c>>d;

system("cls");

cout<<"Sum of FirstNumber: "<<stn.GetFirstNumber()<<endl;
cout<<"Sum of Second Number: "<<stn.GetSecondNumber()<<endl;

cout<<"Sum of Two Numbers: "<<stn.Display();

return 0;
}

these are the errors:
c:\documents and settings\user\desktop\cpp\try\untitled1.cpp(24) : error C2146: syntax error : missing ';' before identifier 'sum'
c:\documents and settings\user\desktop\cpp\try\untitled1.cpp(24) : fatal error C1004: unexpected end of file found


please help me

Recommended Answers

All 8 Replies

You are missing your curly braces that define the function GetFirstNumber() as well as all of the curly braces in the methods of your class.

u should start ur braces at 22 and end them at 42

thank you for replying to my thread, i tried putting the curly braces but the 2 errors became 6..

btw im using Visual C++ 6.0

thank you for replying to my thread, i tried putting the curly braces but the 2 errors became 6..

btw im using Visual C++ 6.0

Well what are the errors?
and can u please paste the code again..

#include<iostream>
     
    #include<cmath>
     
    using namespace std;
     
    class SumTwoNumbers
    {
     
    int nx,ny,sum,suma,sumtn;
     
    public:
    int GetFirstNumber();
    int GetSecondNumber();
    int GetSum(int,int);
     
    void Display(int,int);
     
    }stn;
     
    int SumTwoNumbers::GetFirstNumber()
    {
    sum=nx+ny; //here is where the errors i wrote below points! i dont know why
     
    return(sum);
     
    int SumTwoNumbers::GetSecondNumber()
     
    suma=nx+ny;
     
    return(suma);
     
    int SumTwoNumbers::GetSum()
     
    sumtn=sum+suma;
     
    return(sumtn);
     
    int SumTwoNumbers::Display()
     
    stn.GetSum(sum,suma);
    }
     
    int main()
    {
    int a,b,c,d;
    SumTwoNumbers stn;
     
    cout<<"Enter two Numbers: ";
    cin>>a>>b;
     
    cout<<"Enter two Number: ";
    cin>>c>>d;
     
    system("cls");
     
    cout<<"Sum of FirstNumber: "<<stn.GetFirstNumber()<<endl;
    cout<<"Sum of Second Number: "<<stn.GetSecondNumber()<<endl;
     
    cout<<"Sum of Two Numbers: "<<stn.Display();
     
    return 0;
    }

I already put the curly braces...

here is the errors:
C:\Documents and Settings\user\Desktop\CPP\try\Untitled1.cpp(29) : error C2146: syntax error : missing ';' before identifier 'suma'
C:\Documents and Settings\user\Desktop\CPP\try\Untitled1.cpp(35) : error C2146: syntax error : missing ';' before identifier 'sumtn'
C:\Documents and Settings\user\Desktop\CPP\try\Untitled1.cpp(35) : error C2244: 'SumTwoNumbers::GetSum' : unable to resolve function overload
C:\Documents and Settings\user\Desktop\CPP\try\Untitled1.cpp(41) : error C2146: syntax error : missing ';' before identifier 'stn'
C:\Documents and Settings\user\Desktop\CPP\try\Untitled1.cpp(41) : error C2244: 'SumTwoNumbers::Display' : unable to resolve function overload
C:\Documents and Settings\user\Desktop\CPP\try\Untitled1.cpp(60) : error C2660: 'Display' : function does not take 0 parameters

close the brace at 26
open brace at 28
close the brace at 32
open brace at 34
close the brace at 38
open brace at 40
The display(int,int) definition is missing....
so better change function declaration of display at 17 to Display()
And the same even in case of GetSum() function

its still not working, anyway thank you sharathg.satya for your time helping me..

it seems i need to accept losing some points in grades, haha.. this should be passed on 12 midnight GMT +8

thnx again

its still not working, anyway thank you sharathg.satya for your time helping me..

it seems i need to accept losing some points in grades, haha.. this should be passed on 12 midnight GMT +8

thnx again

welcome
but what's the problem still?
Are there any errors left over?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.