class Point { private int x, y; public Point() { x = y = 0; } public Point(int x
ID: 674217 • Letter: C
Question
class Point
{
private int x, y;
public Point()
{
x = y = 0;
}
public Point(int xC, int yC)
{
x = xC;
y = yC;
}
public int X
{
get { return x; }
set { x = value; }
}
public int Y
{
get { return y; }
set { y = value; }
}
public string ToString()
{
return "Point: (" + x + ", " + y + ")"; //example: (2,3)
Explanation / Answer
#include <string>
#include "strlib.h"
using namespace std;
class Point {
public:
Point() {
x = 0;
y = 0;
}
Point(int xc, int yc) {
x = xc;
y = yc;
}
int getX() {
return x;
}
int getY() {
return y;
}
string toString() {
return "(" + integerToString(x) + ","
+ integerToString(y) + ")";
}
private:
int x;
int y;
};
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.