constructor ?


Posted on 16th Feb 2014 07:03 pm by admin

i have written this program and made 3 constructors in the class and i want to call them in the main and i cant can any one help me and tell me how could i call them in the main

# include
using namespace std ;
Did you know?Explore Trending and Topic pages for more stories like this.

class Triangle {

private :
float side1 ;
float side2 ;
float side3 ;
public :
Triangle () ;
Triangle (float , float , float ) ;
Triangle ( float[3] ) ;
float printAverage () ;
};

Triangle :: Triangle ()
{
float firstSide , secondSide , thirdSide ;

side1 = firstSide ;
side2 = secondSide ;
side3 = thirdSide ;
}

Triangle :: Triangle ( float firstSide , float secondSide , float thirdSide )
{
side1 = firstSide ;
side2 = secondSide ;
side3 = thirdSide ;
}

Triangle :: Triangle ( float side[3] )
{
side1 = side[0] ;
side2 = side[1] ;
side3 = side[2] ;
}

float Triangle::printAverage ()
{
return ( side1 + side2 + side3 ) / 3 ;
}

int main ()
{
float firstSide , secondSide , thirdSide ;

cout << "Enter First Side : " ;
cin >> firstSide ;
cout << "Enter Second Side : " ;
cin >> secondSide ;
cout << "Enter Third Side : " ;
cin >> thirdSide ;

Triangle tri1 = Triangle () ;
Triangle tri2 = Triangle () ;
Triangle tri3 = Triangle () ;


system("pause");
return 0;

}
No comments posted yet

Your Answer:

Login to answer
88 Like 49 Dislike
Previous forums Next forums
Other forums

I need an iframe that calls up a different page according to the date
hi

I don't know any php (only html) and I urgently need to do the following:

I need a

php/mysql problem
Hey all,

Problem: im trying to setup a shop where people can use a drop-down list to select t

upload photo limits
ive got a upload photo script and im just trying to make more secure currently it limits size and as

my two tables
table1 : col1 = topicid , col2 = topic

table2 : col1 = sentid, col2 = sentence

Cod

PHP, jAVASCRIPT setting input values, why isn't it working?
Hi:

I am calling this javascript:
<script language="javascript">

Map.php
I am a complete beginner to PHP and am looking for some help with a program I am messing around with

filesize() returns 0
I have a socket program that runs in an infinite loop, listening for connections, in this socket I h

Word Trimming
Hi Guys & Gals!!

Hope you are all ok....

I need some help with the following

Using CSS to format MySQL query
Hi,

If i want to have a news page on my site, which displays all records of a table in descen

Keeping track of php uploads
Hello all.

I was looking at the way PHP handles file uploads.
It seems that PHP uses a tem

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash