Question


class Point { public: Point() { myX = myY = 0; } Point(int n, int y) { myx = x; myy = y; } int getX() const { return myX; } i

Why is the assertion failing? what code can fix the problem and where should that code be located at?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

read method is reading only and x and y values in Point class so when your calling read () on p2 it is not reading the z value because read() is not available in the Point3D class
so it is not reading n assigning the value to z so override the read in Point3D class and read all 3 values

Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me

Add a comment
Know the answer?
Add Answer to:
Why is the assertion failing? what code can fix the problem and where should that code...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I am having trouble understanding how this code is able to use the contents of the...

    I am having trouble understanding how this code is able to use the contents of the header file. Can someone please provide comments in the main code to describe what is happening? (especially on the bool isNumber) THE MAIN CODE: #include<bits/stdc++.h> #include "MyCartesianPoint.h" #include <math.h> #include <iostream> using namespace std; bool isNumber(string s) {    if(!isdigit (s[0]))    {        if(s[0] != '-')        return false;               else if(s.length() == 1)        return false;...

  • I am having trouble understanding how this code is able to use the contents of the...

    I am having trouble understanding how this code is able to use the contents of the header file. Can someone please provide brief comments in the top code to show what is happening? THE CODE: #include<bits/stdc++.h> #include "MyCartesianPoint.h" #include <math.h> #include <iostream> using namespace std; bool isNumber(string s) {    if(!isdigit (s[0]))    {        if(s[0] != '-')        return false;               else if(s.length() == 1)        return false;    }       for...

  • Java Help 2. Task: Create a client for the Point class. Be very thorough with your...

    Java Help 2. Task: Create a client for the Point class. Be very thorough with your testing (including invalid input) and have output similar to the sample output below: ---After declaration, constructors invoked--- Using toString(): First point is (0, 0) Second point is (7, 13) Third point is (7, 15) Second point (7, 13) lines up vertically with third point (7, 15) Second point (7, 13) doesn't line up horizontally with third point (7, 15) Enter the x-coordinate for first...

  • C++ problem where should I do overflow part? in this code do not write a new...

    C++ problem where should I do overflow part? in this code do not write a new code for me please /////////////////// // this program read two number from the user // and display the sum of the number #include <iostream> #include <string> using namespace std; const int MAX_DIGITS = 10; //10 digits void input_number(char num[MAX_DIGITS]); void output_number(char num[MAX_DIGITS]); void add(char num1[MAX_DIGITS], char num2[MAX_DIGITS], char result[MAX_DIGITS], int &base); int main() { // declare the array = {'0'} char num1[MAX_DIGITS] ={'0'}; char...

  • (Coding done in c++, Virtual Studio) Having a problem with the line trying to compare the...

    (Coding done in c++, Virtual Studio) Having a problem with the line trying to compare the date of birth.            **fall.sort(compare_DOB); //Here lies your error** #include <fstream> #include <iostream> #include <string> #include <list> #include <cctype> using namespace std; const char THIS_TERM[] = "fall.txt"; const string HEADER = "\nWhat do you want to do ?\n\n" "\t. Add a new friend name and DOB ? \n" "\t. Edit/Erase a friend record ? \n" "\t. Sort a Friend's record ? \n"...

  • The following C++ code has a problem where the loop can exceed the size of the...

    The following C++ code has a problem where the loop can exceed the size of the array if the user inputs too many numbers. #include <iostream> using namespace std; int main() { int nums[20] = { 0 }; int a[10] = { 0 }; cout << a << endl; cout << nums << endl; cout << "How many numbers? (max of 10)" << endl; cin >> nums[0]; for (int i = 0; i < nums[0]; i++) { cout << "Enter...

  • I'm getting an Error: LNK1561: entry point must be defined. Can someone edit it with using...

    I'm getting an Error: LNK1561: entry point must be defined. Can someone edit it with using the basic iostream and string libraries, only basic lib. In a population, the birth rate and death rate are calculated as follows: Birth Rate = Number of Births ÷ Population Death Rate = Number of Deaths ÷ Population For example, in a population of 100,000 that has 8,000 births and 6,000 deaths per year, Birth Rate = 8,000 ÷ 100,000 = 0.08 Death Rate...

  • Cant find what is wrong to fix the code. can you please fix the code. The...

    Cant find what is wrong to fix the code. can you please fix the code. The function is: sin^-1 (x/5) #include <iostream> #include <iomanip> #include <math.h> #include <cmath> using namespace std; double f(double x) { return pow(sin, -1)*(x / 5); } int main() { int i, n; double a = 0.0, b =1.0, h, s = 0.0, x, xbar; double s1, s2, s3; cout << " Enter # of partitions n "; cin >> n; cout << " n =...

  • I've posted 3 classes after the instruction that were given at start You will implement and...

    I've posted 3 classes after the instruction that were given at start You will implement and test a PriorityQueue class, where the items of the priority queue are stored on a linked list. The material from Ch1 ~ 8 of the textbook can help you tremendously. You can get a lot of good information about implementing this assignment from chapter 8. There are couple notes about this assignment. 1. Using structure Node with a pointer point to Node structure to...

  • Can some one fix my code so that the output result same as below? BAR PLOT...

    Can some one fix my code so that the output result same as below? BAR PLOT OF CYLINDER PRESSURE -VS- TIME pressure is on horizontal axis - units are psi time is on vertical axis - units are msec    0.0         20.0        40.0          60.0        80.0       100.0      120.0       +---------+---------+---------+---------+---------+---------+ 0.0|************************* 1.5|********************************* 3.0|***************************************** 4.4|**************************************************      05.9|********************************************* 7.4|******************************** 8.9|*********************** 10.4|***************** 11.9|************** 13.3|************* 14.8|************ 16.3|********* 17.8|******* 19.3|****** 20.7|****** 22.2|******* 23.7|******* .......... ===================== her is my code //#include"stdafx.h" #include #include #include #include #include #include using...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT