error coming in the following code (member identifier expected)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rahuldhawan123
    New Member
    • Apr 2014
    • 1

    error coming in the following code (member identifier expected)

    Code:
    #include<iostream.h>
    #include<conio.h>
    class figure
    	{
    	public:
    		virtual void Area();
    	};
    class square:public A
    	{
    	public:
    		void Area()
    			{
    			int side,x;
    			cout<<"\nEnter the SIDE of the square\t";
    			cin>>side;
    			x=side*side;
    			cout<<"\nThe AREA of the SQUARE is\t"<<x;
    			}
    	};
    class Rectangle:public figure
    	{
    	public:
    		void Area()
    			{
    			int l,b,y;
    			cout<<"\nEnter the LENGTH of the rectangle\t";
    			cin>>l;
    			cout<<"\nEnter the BREADTH of the rectangle\t";
    			cin>>b;
    			y=l*b;
    			cout<<"\nThe AREA of the rectangle is\t"<<y;
    			}
    	};
    class Traingle:public figure
    	{
    	public:
    		void Area()
    			{
    			int b1,h,z;
    			cout<<"\nEnter the BREADTH of the traingle\t";
    			cin>>b1;
    			cout<<"\nEnter the HIEHGHT of the traingle\t";
    			cin>>h;
    			z=0.5*b1*h;
    			cout<<"\nThe AREA of the traingle is\t"<<z;
    			}
    	};
    void main()
    	{
    	clrscr();
    	figure f;
    	square s;
    	Traingle t;
    	Rectangle r;
    	f.void Area();
    	s.void Area();
    	t.void Area();
    	r.void Area();
    	getch();
    	}
    Last edited by Rabbit; Apr 30 '14, 04:36 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • stdq
    New Member
    • Apr 2013
    • 94

    #2
    In line 8, you inherit from class A. Where is that class defined? Also, in which line(s) does the compiler/linker tells the error is in?

    Comment

    • maya29988
      New Member
      • May 2014
      • 7

      #3
      You just need to call in this way "f.Area()" not like this "f.void Area()".

      syntax should be object.<functio nName>

      Comment

      Working...