No designer - circumference
-
Parameter circumference: centre coordinates, radius. Methods: Procedure for initialization of fields, procedure for displaying the object ' s field values and function for determining whether a point is located at coordinates x,y inside the circumference. Created as he could, when compiling makes error: ‘x’ was not declared in this scope
#include <iostream> #include <cmath> using namespace std; class Circle { private: double x; double y; double r; public: Circle(); Circle(double x=2, double y=2, double r=5);
};
int Main(){
if (xx+yy<=r*r)
{
cout << "Точка принадлежит окружности." << endl;
}
else
{
cout << "Точка не принадлежит окружности." << endl;
}
return 0;
}
-
Your function.
int Main()
is not a class method (based outside) and therefore knows nothing about variablesx, y, r
but you use them in this function.class Circle { private: double x; double y; double r; public: Circle(); Circle(const double x0=2, const double y0=2, const double r0=5);
int Main();
};
int Circle::Main(){
if (xx+yy<=r*r)
{
cout << "Точка принадлежит окружности." << endl;
}
else
{
cout << "Точка не принадлежит окружности." << endl;
}
return 0;
}
I really suspect it.
Main()
whichmain()
usually :P. S.
class Circle
{
private:
double x;
double y;
double r;
public:
Circle();
Circle(const double x0=2, const double y0=2, const double r0=5);void show();
};
Circle::Circle()
: x(0), y(0), r(0)
{}Circle::Circle(const double x0, const double y0, const double r0)
: x(x0), y(y0), r(r0)
{}int Circle::show(){
if (xx+yy<=r*r)
{
cout << "Точка принадлежит окружности." << endl;
}
else
{
cout << "Точка не принадлежит окружности." << endl;
}
return 0;
}
and use in the main code, for example:
Circle obj(10, 20, 5);
obj.show();