C++
Do not use constructors
Create a class named Coord in C++
Class has 3 private data items
int xCoord;
int yCoord;
int zCoord;
write the setters and getters. They should be inline functions
void setXCoord(int) void setYCoord(int) void setZCoord(int)
int getXCoord() int getYCoord() int getZCoord()
write a member function named void display() that displays the data items in the following format
blank line
xCoord is ????????
yCoord is ????????
zCoord is ????????
Blank line
Example
blank line
xCoord is 101
yCoord is -234
zCoord is 10
Blank line
class Coord {
private:
int xCoord;
int yCoord;
int zCoord;
public:
void setXCoord(int x) {xCoord = x;}
void setYCoord(int x) {yCoord = x;}
void setZCoord(int x) {zCoord = x;}
int getXCoord() {return xCoord; }
int getYCoord() {return yCoord; }
int getZCoord() {return zCoord; }
void display()
{
cout<<'\n';
cout<<"xCoord is"<<'\t'<<xCoord<<'\n';
cout<<"yCoord is"<<'\t'<<yCoord<<'\n';
cout<<"zCoord is"<<'\t'<<zCoord<<'\n';
cout<<'\n';
}
};
Get Answers For Free
Most questions answered within 1 hours.