[Cpp]/* 02. * copyright and version Declaration of the program part 03. * Copyright (c) 2012, Yantai University Computer college student 04. * All rightsreserved. 05. * file name: object. cpp 06. * Author: Dong Wanpeng 07. * Completion Date: April 8, March 22, 2013. * version: v1.0 09. * input Description: None. 10. * Problem description: design a class that calculates the circumference and area of a triangle. 11. * program output: the circumference and area of the triangle are 12. */# include <iostream> # include <Cmath> using namespace std; class Triangle {public: inline void setA (double x); inline void setB (double y ); inline void setC (double z); // set the value of the three sides. Be sure to convert it into a triangle inline double getA (); inline double getB (); inline double getC (); bool isTriangle (); double perimeter (void); // calculate the triangle perimeter double area (void); // calculate and return the Triangle area private: double a, B, c; // The three sides are private member data}; inline void Triangle: setA (double x) {a = x;} inline void Triangle: setB (double y) {B = y;} inline void Triangle: setC (double z) {c = z;} bool Triangle: isTriangle () {if (a + B)> c) & (a + c)> B) & (B + c)> a) & (a-B) <c) & (a-c) <B) & (B-c) <a) return true; else return false;} inline double Triangle: getA () {return a;} inline double Triangle: getB () {return B;} inline double Triangle: getC () {return c;} double Triangle: perimeter () {return (a + B + c);} double Triangle: area () {double area, p; p = (a + B + c)/2; area = sqrt (p * (p-a) * (p-B) * (p-c); return area;} int main () {Triangle tri1; // define an instance (object) of the triangle class 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 ;}