[Cpp]/** Copyright and version statement of the program section * Copyright (c) 2012, student * All rightsreserved from computer College of Yantai University. * file name: object. cpp * Author: Ji Zilong * Completion Date: July 15, March 21, 2013 * version: v1.0 * input Description: none * Problem description: design the class of triangle circumference and area. * Program output: Triangle length and area */# include <iostream> # include <Cmath> using namespace std; class Triangle {public: inline void setA (double x) // set the value of the three sides. Note that the triangle {a = x;} inline void setB (double x) {B = x;} inline void setC (double x) {c = x;} inline int getA () // obtain the value {return a;} inline int getB () {return B;} inline int getC () {return c;} double perimeter (void); // calculate the triangle perimeter double area (void); // calculate and return the Triangle area bool isTriangle (); // determine whether the Triangle type is private: double a, B, c; // the three sides are private member data}; double Triangle: perimeter (void) // calculate the perimeter of the Triangle {return a + B + c;} double Triangle: area (void) // calculate and return the Triangle Area {int s = (a + B + c)/2; return sqrt (s * (s-a) * (s-B) * (s-c);} bool Triangle: isTriangle () {if (a + B)> c & (a-B) <c) return true; else return false;} int main () {Triangle tri1; // defines an instance of the Triangle class (object) double x, y, z; cout <"Enter the three sides of the triangle:"; cin> x> y> z; tri1.setA (x); tri1.setB (y); tri1.setC (z ); // if (tri1.isTriangle () {cout <"three sides:" <tri1.getA () <',' <tri1.getB () <',' <tri1.getC () <endl; cout <"Triangle perimeter:" <tri1.perimeter () <'\ t' <"Area:" <tri1.area () <endl;} else cout <"cannot form a triangle" <endl; system ("pause"); return 0;} running result: