Error !!! Undefined Symbol a1

Discussion in 'C++' started by vikas rudani, Feb 1, 2011.

  1. vikas rudani

    vikas rudani Banned

    Joined:
    Aug 1, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    GOOD JOB
    Location:
    ANAND,GUJARAT
    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();
    }
     
    Last edited by a moderator: Feb 1, 2011
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,335
    Likes Received:
    377
    Trophy Points:
    83
    Why do you expect that it should be defined symbol?
     
  3. alpha34

    alpha34 New Member

    Joined:
    Dec 2, 2009
    Messages:
    25
    Likes Received:
    1
    Trophy Points:
    0
    Occupation:
    student
    Location:
    somewhere in india
    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....
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice