p1.cpp 1 #include #include 3 #include #include #include 6 5 using namespace std; #include "pl.h" // Implement your member functions in this file 10 11 9 p1.h #ifndef P1 H #define P1 H 1 4. #include class Point30 { // Add your class members here 9 }: 10 11 fendif xercise.cpp #include 2 #include

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
p1.cpp
#include <cmath>
#include <string>
#include <iostream>
#include <sstream>
#include <iomanip>
6 using namespace std;
#include "pl.h"
// Implement your member functions in this file
10
9
11
p1.h
#ifndef P1 H
#define P1 H
1
#include <string>
#include <iostream>
class Point3D
7
{
// Add your class members here
};
10
9
11
#endif
xercise.cpp
1 #include <iostream>
#include <string>
3 using namespace std;
#include "pl.h"
int main()
{
// Add any code you want to run here
// You do NOT have to add any code here.
// Point30 p(1.5, 2.5, 3.5);
10
11
12
Transcribed Image Text:p1.cpp #include <cmath> #include <string> #include <iostream> #include <sstream> #include <iomanip> 6 using namespace std; #include "pl.h" // Implement your member functions in this file 10 9 11 p1.h #ifndef P1 H #define P1 H 1 #include <string> #include <iostream> class Point3D 7 { // Add your class members here }; 10 9 11 #endif xercise.cpp 1 #include <iostream> #include <string> 3 using namespace std; #include "pl.h" int main() { // Add any code you want to run here // You do NOT have to add any code here. // Point30 p(1.5, 2.5, 3.5); 10 11 12
Implement the class Point3D. Put the class definition in the header p1.h and the implementation in the p1.cpp file. You
may not have any inline functions defined in the header file. Use the file xercise.cpp to check if your implementation is
syntactically correct.
• The class has three data members: x, y, and z, which are double.
• The default constructor initializes the Point3D to the origin (0, 0, 0), while the working constructor supplies values
for x, y, and z: all doubles in that order.
• Create accessors getX(), getY() and getZ(). There are no mutators. (The class is immutable)
• Write a member function distance() that returns the distance between the current Point3D (the implicit parameter
which will be the left-hand side of an expression) and a second Point3D passed as an explicit parameter (which will
be the right-hand-side of the expression). Here is the distance formula for a 3D point:
V (xI -x: 5+ (yı -y: )+ (zı -z: }
+ (yı -y2 )'+ (zı
-Z2
You must both define and implement a feature for the tests to run. For instance, if you define getX() but fail to
implement it, then your code will not compile. If your code fails to compile, comment out both the definition and the
implementation of the feature that fails.
Transcribed Image Text:Implement the class Point3D. Put the class definition in the header p1.h and the implementation in the p1.cpp file. You may not have any inline functions defined in the header file. Use the file xercise.cpp to check if your implementation is syntactically correct. • The class has three data members: x, y, and z, which are double. • The default constructor initializes the Point3D to the origin (0, 0, 0), while the working constructor supplies values for x, y, and z: all doubles in that order. • Create accessors getX(), getY() and getZ(). There are no mutators. (The class is immutable) • Write a member function distance() that returns the distance between the current Point3D (the implicit parameter which will be the left-hand side of an expression) and a second Point3D passed as an explicit parameter (which will be the right-hand-side of the expression). Here is the distance formula for a 3D point: V (xI -x: 5+ (yı -y: )+ (zı -z: } + (yı -y2 )'+ (zı -Z2 You must both define and implement a feature for the tests to run. For instance, if you define getX() but fail to implement it, then your code will not compile. If your code fails to compile, comment out both the definition and the implementation of the feature that fails.
Expert Solution
steps

Step by step

Solved in 5 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY