// triangle.hThis was just a C++ style single line comment. Any line that begins with two forward slashes is considered a comment up to the end of the line.
class trianglesaid that we were starting the definition of the triangle object. You can think of the class keyword as being like the struct keyword, except that class's can do much much more.
public:said that the stuff that follows can be used by anything. In contrast, the line
private:said that the stuff that follows can be used only by internal object functions. To give an example, say that I declare a triangle variable with the line
triangle t;Then the following lines are fine
t.setTriangle( 3, 4, 5 );
if ( t.valid() )
printf( "%d", t.area() );
But
t.s1 = 5.0;isn't because s1 is a private data member of t and in C++, no one else can see your private parts.
object-name . member-function-name ( function-arguments );
triangle(double side1, double side2, double s3);Then we could either declare triangle objects like we did before with
triangle t1, t2;or using the new construct:
triangle rightT(3.0, 4.0, 5.0 );