gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
Sure, here is another C++ program on class Point using C++ class basics:
- User
Sure, here is another C++ program on class Point using C++ class basics:
- Assistant
#include using namespace std;
class Point { private: int x; int y;
public: Point() { x = 0; y = 0; }
Point(int xCord, int yCord) { x = xCord; y = yCord; } void setX(int xCord) { x = xCord; } void setY(int yCord) { y = yCord; } int getX() { return x; } int getY() { return y; }};
int main() { Point p1; // Default constructor cout << "Default point is (" << p1.getX() << ", " << p1.getY() << ")" << endl;
Point p2(3, 8); // Parameterized constructor cout << "Point is (" << p2.getX() << ", " << p2.getY() << ")" << endl; p2.setX(5); p2.setY(12); cout << "Updated point is (" << p2.getX() << ", " << p2.getY() << ")" << endl; return 0;