...
inline double square(double x){return x*x; }
int main()
{
double a, b;
double c=13.0;
a = square(5.0);
b = square(4.5 + 7.5);
cout<<"a = "<<a<<" , b = "<<b<<endl;
cout<<"c = "<<c<<" and c squared = "<<square(c)<<endl;
}
#define SQUARE(x) ((x) * (x)) //这里括号是为了确保括号内是表达式也能达成预期的效果
网友评论