I know that i have alot of code yet to go I just do not understand exactly how to get void Triangle::setBottomLeftX(const double x) to work.
Implement the get and set member functions for the class Triangle. Use the appropriate class
attributes of the class Triangle.
a. The location of the bottom left vertex is stored in the member attribute blPoint.
b. The top left vertex can be computed from blPoint and the height.
c. The bottom right vertex can be computed from blPoint and the length.
Your Triangle class has an attribute (also known as a data member) called blPoint.
That should be used to store the coordinates of the bottom-left vertex of the triangle.
Since data members are private (unless there's a VERY good reason for them not to be), other code can't simply set the value of that attribute. So your class has to supply a method that other code can call to set the value. That method is setBottomLeftX.
When you post code here, please use the code tags, to make it more readable.
You're getting the idea. Each class keeps its own data (i.e. attributes) private, and provides a public interface (public methods) for other classes to call.
So Point keeps its px and py members private, so that Triangle can't set them directly (and nor can any other class). Instead, Point should have get* and set* methods to allow other classes to set and retrieve the values. Methods in Triangle will then call these methods, rather than trying to directly access the attributes.
Similarly, Triangle's attributes are private, and other code can't directly access them. Triangle will have get* and set* methods of its own.
For return (blPoint + height); , and return (blPoint + height); it is giving me an error saying that no match for 'operator+' in ... what am i doing wrong here?
You're trying to add the values of an integer and a Point class. Since Point is your class, the compiler doesn't know how to do this addition. If you want to perform an addition of these two types, you'll need to define your own "+" operator that does it.
Why are you trying to do this addition? It doesn't seem to have anything to do with getting the value of a data attribute, which is what your get* methods should be doing.
Edit: And please could you put your code in code tags when posting it?
I am trying to find the bottom right and top left points of the triangle, which would be just the bottom left point plus the length or height.
So now for these sections I have: return (blPoint.setX(x)+ length);
And: return (blPoint.setY(y)+ length);
But I am getting an error that says x and y are not defined in the scope and not quite sure how to fix it.
Point::setX(double) is a function that changes the value of Point.px and does not return any value. You cannot compute (void + double).
1 2 3 4
Point Triangle::getBottomRight() const
return // What?
Return type is Point, not a double. Obviously, you must create a Point.
Qualifier is const. This function cannot change this triangle. It cannot change the member variables of the class. blPoint is a member variable. Therefore, you can call only member functions blPoint that are const.
The problem was that he was using method names as if they were variable names when trying to call them. The changes were simply to use the correct syntax for calling a function, which can be found in any rudimentary C or C++ tutorial, such as: