编译的时候显示对重载函数调用不明确,求大神解答
#include <iostream>
#include "Circle2.h"
using namespace std;
void printCircle(Circle2 c)
{
cout << "The area of the circle of "
<< c.getRadius() << " is " << c.getArea() << endl;
}
void printCircle(Circle2 *c)
{
cout << "The area of the circle of "
<< c->getRadius() << " is " << c->getArea() << endl;
}
void printCircle(Circle2 &c)
{
cout << "The area of the circle of "
<< c.getRadius() << " is " << c.getArea() << endl;
}
int main()
{
Circle2 myCircle(5.0);
//printCircle(myCircle); 这句调用时显示对重载函数调用不明确,为什么?注释掉就好了
Circle2 myCircle2(10.0);
printCircle(&myCircle2);
Circle2 myCircle3(20.0);
printCircle(&myCircle3);
return 0;
} |