I am not sure if this is how it should be written.
Give the two dimensional point, write codes to make a new
Point object and set its x variable to 4 and y variable to 2. Add a constructor to
Point class that gives x and y initial values.
class Point {
float x;
float y;
}
my answer:
class Point {
float x;
float y;
float x = 4;
float y = 2;
// constructor
Point(float init_x, float init_y) {
x = init_x;
y = init_y;
)
}
Am I doing this right? Please advise me. Help is greatly appreciated.