Clean and rebuild.
That is normal output. Nothing wrong there.
You should be looking at the black console window that pops up.
What does redefine mean in this context?But I do have a program related question. I am supposed to redefine two of the objects and then print their outputs. How do I redefine an object. I have what I tried in comment brackets on my main.cpp and received an error when trying that.
I have my 5 objects and I should print the length, width, area, and perimeter. Then I should set new parameter to object one and four and then print their values.
And to the black window comment, nothing shows on it not even "..."
Last edited by LearnOnTheFly; 02-17-2013 at 11:24 PM.
@LearnOnTheFly
Please make sure you "paste as text" when copy/pasting things from your IDE.
Your pastes are full of whatever passes for HTML, and it confuses the hell out of the board to make a decent presentation of it.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
Ok, thanks iMalc.
I'm still struggling to solve how redefine objects. I have the five in man and then print their values. How can I set new parameters to the 2 of the objects after displaying the values, then display the new values?
Got it. Sorry, it's taken a bit for object-oriented to soak in. Is there anyway to declare the object name in the print function. I know I can use a cout in main with each object name before calling the print function but I am supposed to use the print function for all display is possible.
Also, how would you take the result from the boolean function and print "This is a square" if the result of the boolean function was true in the print the function. I know I can call the function but not sure how to write a cout statement based on the result. I have looked for examples with no luck.
Last edited by LearnOnTheFly; 02-18-2013 at 08:38 PM.
Ok, I have my boolean function working in print but when I set new values to object 1 from no parameters to length = 5.4 and width = 10.5 it says its still a square
Code:int main() { Rectangle object1; Rectangle object2 (7.1, 3.5); Rectangle object3 (6.3); Rectangle object4 (21, 22); Rectangle object5 = object2; object1.printData(); object2.printData(); object3.printData(); object4.printData(); object5.printData(); object1.setLength(5.4); object1.setWidth(10.5); object4.setLength(15.6); object4.setWidth(15.6); object1.printData(); object4.printData(); int c; while((c = getchar()) != '\n' && c != EOF); }Code:Rectangle::squareTest(double L, double W) const { if (L-W < .0001){ return true; } else{ return false; } } void Rectangle:printData() { cout<< "\nLength: " << length; cout<< "\nWidth: "<< width; cout<< "\nArea: " << calcArea(); cout<"\nPerimeter: " << calcPerimeter(); if (squareTest(length, width)){ cout<<"\nThis is a square"; } else{ cout<<"\nThis is a rectangle"; }
Mmm, now would be an excellent time to try out the debugger.
See if you can spot the error. Will do you good practice.