error C2064: term does not evaluate to a function
#include<iostream>#include<math.h>
using namespace std;
class Shape
{
public:
virtual void ShapeName() const=0;
};
class Circle:public Shape
{
public:
Circle(double r):radius(r){}
double area(){return(3.14159*radius*radius);}
virtual void ShapeName() const {cout<<"Circle:";}
virtual void printArea();
protected:
double radius;
};
void Circle::printArea()
{cout<<Circle::area()<<endl;}
class Rectangle:public Shape
{
public:
Rectangle(float l,float w):length(l),width(w){}
float area(){return length*width;}
virtual void ShapeName() const {cout<<"Rectangle:";}
void printArea();
protected:
float length;
float width;
};
void Rectangle::printArea()
{cout<<Rectangle::area()<<endl;}
class Triangle:public Shape
{
public:
Triangle(float x=0,float y=0,float z=0);
float area()
{
float p;
p=(x+y+z)/2;
return sqrt(p(p-x)(p-y)(p-z));
}
virtual void ShapeName() const {cout<<"Triangle:";}
void printArea();
protected:
float x;
float y;
float z;
};
void Triangle::printArea()
{cout<<Triangle::area()<<endl;}
int main()
{
Circle a(2);
Rectangle b(5,3.5);
Triangle c(2,3,4);
a.printArea();
b.printArea();
c.printArea();
return 0;
}
出现2.cpp(42) : error C2064: term does not evaluate to a function如何解决