// Coords.h
#include
Copyright By PowCoder代写 加微信 powcoder
using namespace std;
class Coords
{ private:
int xc, yc;
Coords(int x, int y);
void print(ostream &str) const;
// Coords.cpp
#include
#include “Coords.h”
using namespace std;
Coords::Coords(int x, int y)
void Coords::print(ostream &str) const
{ str << '(' << xc << ',' << yc << ')';
// part(b)
Coords::Coords(int x, int y): xc(x), yc(y)
// part (c)(i)
// p%q interpreted as p.operator%(q) or operator%(p,q)|
// need p.operator%(q) since question asks for a member of the class
// add to public part of header file
float operator%(const Coords &q) const; // could use double
// add to cpp file
#include
float Coords::operator%(const Coords &q) const
{ float xdist = xc-q.xc;
float ydist = yc-q.yc;
return sqrt(xdist*xdist+ydist*ydist);
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com