/** Copyright and version declaration section of the Program * copyright (c) 2012, student * All rightsreserved from computer College of Yantai University. * file name: X. CPP * Author: Xu Benxi * Completion Date: July 15, March 29, 2013 * version: V1.0 * input Description: * Problem description: default constructor and constructor with parameters * program output: * // my code: # include <iostream> # include <cmath> using namespace STD; Class triangle {public: triangle (Double X, Double Y, Double Z ); triangle (); double perimeter (void); // calculate the triangle perimeter double area (void); // calculate and return the Triangle Area void showmessage (); Private: bool istriangle (); // Determine whether the triangle is double A, B, C; // the three sides are private member data}; bool triangle: istriangle () // determine whether the triangle is {double num; int I = 0; bool T = true; do {if (a + B> C & a-B <c) {num = A; A = B; B = C; C = num; I ++;} else {cout <"three sides cannot form a triangle! "; T = false; break;} if (I = 3) break;} while (I <= 3); Return t;} double triangle: Perimeter () {return (A + B + C);} double triangle: Area () {Double Z; Z = (A + B + C)/2; return (SQRT (z * (Z-a) * (Z-B) * (Z-C);} triangle: triangle () {A = 1; B = 1; C = 1;} triangle: triangle (Double X, Double Y, Double Z) {A = x; B = y; C = z;} void triangle:: showmessage () {If (istriangle ()) {cout <"the three sides of the triangle are respectively" <A <'\ t' <B <' \ t' <C <Endl; cout <"the circumference of the triangle is:" <perimeter () <'\ T' <"Area:" <area () <Endl;} elsecout <"cannot be a triangle! "<Endl;} void main (void) {triangle tri1; // defines an instance (object) of the triangle class. A default constructor is required. The initial values of the three sides are 1tri1. showmessage (); triangle tri2 (7,8, 9); // defines an instance (object) of the triangle class tri2.showmessage ();}