/** Copyright (c) 2012, School of Computer Science, Yantai University * All Rights Reserved. * file name: 123.cpp * Author: Qiu xuewei * Completion Date: July 15, March 29, 2013 * version No.: V1.0 * input Description: none * Problem description: constructor of default function * program output: slightly * Problem Analysis: slightly Algorithm Design: slightly */# include <iostream> # include <cmath> using namespace STD; Class triangle {public: triangle (Double X = 1, double Y = 1, Double Z = 1); double perimeter (void); // calculate the perimeter of the triangle double area (void ); // calculate and return the Triangle Area void showmessage (); Private: Double A, B, C; // the three sides are private member data}; triangle: triangle (Double X, double Y, Double Z) {A = x; B = y; C = z;} void triangle: showmessage () {cout <"the three sides of the triangle are respectively: "<A <" "<B <" "<C <Endl; cout <" the circumference of the triangle is: "<perimeter () <'\ t' <"Area:" <area () <Endl;} double triangle: Perimeter () {return A + B + C ;} double Triangle: Area () {double D = (A + B + C)/2; return SQRT (D * (d-a) * (D-B) * (D-C);} void main (void) {triangle tri1; // defines an instance (object) of the triangle class. A default constructor must be executed, 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 ();}