expression-cannot-be-used-as-a-function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 1033SN
    New Member
    • Sep 2018
    • 1

    expression-cannot-be-used-as-a-function

    so i see this error constantly,here is my code, can someone help me please?thanks in advance
    Code:
    #include <iostream> 
    using namespace std; 
    class area 
    { 
     
     public: 
     float  Area ,length, width, Perimeter,sqrt,coordinates;
     float P1, P2, P3, P4;  
     int x1,x2,x3,x4,y1,y2,y3,y4; 
     
    
    {
      
    P1=0; 
    P2=0; 
    P3=0; 
    width=1; 
    length=1; 
    coordinates=0; 
    Area=0; 
    Perimeter=0;
     } 
     void setcoordinates()
      { 
      Rectangle:
       cout<<"enter value of coordinates x1,x2,x3,x4,y1,y2,y3,y4"<<endl; 
       cin>>x1>>x2>>x3>>x4>>y1>>y2>>y3>>y4;
        P1 = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1)); 
    	P2 = sqrt((x4 - x3)*(x4 - x3) + (y4 - y3)*(y4 - y3)); 
    	P3 = sqrt((x3 - x2)*(x3 - x2) + (y3 - y2)*(y3 - y2)); 
    	if (x1>0,x2>0,x3>0,x4>0,y1>0,y2>0,y3>0,y4>0)
    	 {
    	  cout<<"Rectangle in 1st Coordinate"<<endl;
    	   }
    	    else {
    		 cout<<"Rectangle is not in 1st coordinate"<<endl;
    		 goto Rectangle; 
    		 } 
    		 if(P1!=P2) 
    		 { 
    		 cout<<"Rectangle is not valid"; goto Rectangle;
    		  } 
    		  }
    		  
    void setwidth()
    
     
     { Rectangle:
      cout<<"width of rectangle: ";
       width=P1; 
       cout<<width; 
       cout<<endl; 
       if( width>20)
        { 
    	cout<<"width is greater than 20"; 
    	goto Rectangle; 
    	} 
    	
    	else if (width <=0) 
    	{ 
    	cout<<"width is equal or less than 0"<<endl;
    	 goto Rectangle;
    	  } 
    	  } 
    void setlength()
     {
      Rectangle:
       cout<<"length of rectangle: "; 
       length=P3;
        cout<<length; 
    	cout<<endl; 
    if(length>20)
     {
      cout<<"length is greater than 20."<<endl; 
      goto Rectangle;
       }
        else if(length<=0) 
    	{
    	 cout<<"length is equal or less than 0."<<endl; 
    	 goto Rectangle;
    	  } 
    	  }
    	  
    	  void calculate() 
    	  {
    	   Area=width*length; 
    	   Perimeter=2*width+2*length;
    	  }
    	  
    	   void show()
    	    { 
    		cout<<"width and length are less than 20 and greater than 0." <<endl; 
    		cout<<"Area of rectangle = "<<Area<<endl;
    		 cout<<"Perimeter of rectangle = "<<Perimeter<<endl;
    		  if(P1=P3)
    		   {
    		    cout<<"it is a Square"<<endl;
    			 } 
    			 else
    			  { cout<<"it is not a square";
    			   }
    			    }
    				 };
    
     
    int main()
     {
      Rectangle: 
      area c; 
      c.setcoordinates();
       c.setwidth(); 
       c.length(); 
       c.calculate();
        c.show(); 
    	return 0; 
    	}
    Last edited by zmbd; Sep 8 '18, 02:04 AM. Reason: [z{please use the [CODE/] formatting tool when posting code/script/tables :) }]
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    What is this:

    Code:
    {
      
    P1=0; 
    P2=0; 
    P3=0; 
    width=1; 
    length=1; 
    coordinates=0; 
    Area=0; 
    Perimeter=0;
     }
    It's not a function. It's a declared scope so anything done between the braces is deleted at the end of the scope. Probably this is what the compiler is trying to tell you.

    Comment

    Working...