#include<iostream>
using namespace std;
class CCircle
{
private:
int a,b,r;
double area;
public:
CCircle();
CCircle(const int r);
CCircle(const int a,const int b);
CCircle(const int a,const int b,const int r);
double GetArea();
void Print();
};
CCircle::CCircle()
{
cout << "생성자1" << endl;
this->a=0;
this->b=0;
this->r=1;
Print();
}
CCircle::CCircle(int r)
{
cout << "생성자2" << endl;
this->a=0; this->b=0;
this->r=r;
Print();
}
CCircle::CCircle(int a, int b)
{
cout << "생성자3" << endl;
this->a=a;
this->b=b;
r=1;
Print();
}
CCircle::CCircle(int a,int b,int r)
{
cout << "생성자4" << endl;
this->a=a;
this->b=b;
this->r=r;
Print();
}
double CCircle::GetArea()
{
double PI=3.14;
area=PI*PI*this->r;
return area;
}
void CCircle::Print()
{
cout << "중심 좌표는 : " << "("<<a<<","<<b<<")" << " " << "반지름 길이는 : "<< r<< endl;
cout << "원의 넓이는 : " << GetArea() << endl;
}
int main()
{
int a,b,r;
cout << "중심좌표, 반지름 입력 : ";
cin >> a >> b >>r;
CCircle();
CCircle(r);
CCircle(a,b);
CCircle(a,b,r);
return 0;
}
1>c:\users\asusss\documents\visual studio 2010\projects\과제\과제\ss.cpp(66): error C2371: 'r' : 재정의. 기본 형식이 다릅니다.
1> c:\users\asusss\documents\visual studio 2010\projects\과제\과제\ss.cpp(61) : 'r' 선언을 참조하십시오.
이렇게 나옵니다. 왜그런지 도저히 못찾겟어요...