Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Error !!! Undefined Symbol a1 (http://www.go4expert.com/forums/error-undefined-symbol-a1-t24820/)

vikas rudani 1Feb2011 14:46

Error !!! Undefined Symbol a1
 
Code:

#include<iostream.h>
#include<conio.h>
class addition
{
    public:
    int a,b,sum;
    float c,d,sum1;
    int add(int,int);
    float add(float,float);
    int mul(int,int);
    float mul(float,float);
    void getdata()
    {
        cout<<a;
        cout<<b;
        cout<<c;
        cout<<d;
    }

};
int addition :: add(int x,int y)
{
    sum=x+y;
    return sum;
}
float addition :: add(float x,float y)
{
    sum1=x+y;
    return sum1;
}
int addition :: mul(int x,int y)
{
    sum=x*y;
    return sum;
}
float addition :: mul(float x,float y)
{
    sum1=x*y;
    return sum1;
}
void main()
{
    clrscr();
    addition a;
    a.getdata();
    int a2=a1.add(a1.a,a1.b);
    float a3=a1.add(a1.c,a1.d);
    int a4=a1.mul(a1.a,a1.b);
    float a5=a1.mul(a1.c,a1.d);
    cout<<"\n Addition int "<<a2;
    cout<<"\n Adition Float"<<a3;
    cout<<"\n Multiplication int "<<a4;
    cout<<"\n Multiplication float"<<a5;
    getch();
}


shabbir 1Feb2011 18:07

Re: Error !!! Undefined Symbol a1
 
Why do you expect that it should be defined symbol?

alpha34 1Feb2011 18:18

Re: Error !!! Undefined Symbol a1
 
its showing u error coz u r using a1 as a member access u need to define a class variable as addition a1
and then use a1 and it will work fine.....always c++ needs a variable which acts as a class which inturn can access class objects and methods....


All times are GMT +5.5. The time now is 22:45.