Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use the code provided. / Overload assignment. Coord Coord::operator=(Coord rght) { setXCoord( right.getXCoord()); setYCoord( right.getYCoord()); setZCoord( right.getZCoord()); return *this; } _______________________________________________ /**************************************************** program name: Coord04*


use the code provided.

/ Overload assignment. Coord Coord::operator=(Coord rght) { setXCoord( right.getXCoord()); setYCoord( right.getYCoord()); setZCoord( right.getZCoord());

return *this; }

_______________________________________________

/**************************************************** program name: Coord04* Author: Sanjog Nepal* date due: 10/28/20* remarks:*****************************************************//******************************************* library includes******************************************/#include // needed for cin and cout/******************************************* pre-processor******************************************/#define PI 3.14159using namespace std;class Coord {private: // Change instance variables to pointers int *xCoord; int *yCoord; int *zCoord;public: // Alloacate memory in the constructor Coord() { xCoord = new int; yCoord = new int; zCoord = new int; } // Free memory in the destructor ~Coord() { delete xCoord; delete yCoord; delete zCoord; } // Change the setters to take in pointers void setXCoord(int *x) {xCoord = x;} void setYCoord(int *x) {yCoord = x;} void setZCoord(int *x) {zCoord = x;}// Change getters to return the values pointed by pointers int getXCoord() {return *xCoord; } int getYCoord() {return *yCoord; } int getZCoord() {return *zCoord; }// Display the values void display() { cout cout\"xcoord> cout\"ycoord> cout\"zcoord> cout }};/***************************************** main()*****************************************/int main(){ Coord c; // Create class object int x = 10, y = 20, z = 30; // Create 3 variables for x, y and z coord's c.setXCoord(&x); // Set x coord c.setYCoord(&y); // Set y coord c.setZCoord(&z); // Set z coord c.display(); // Display the coord values // Display the coord values using getters cout cout cout system(\"pause\"); return 0;}




Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

=+a) Was this an observational study or an experiment?

Answered: 1 week ago