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 ;

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

Extract specific information from a PHP Multidimensional Array
Howdy! I've racked my brain over this for 24 hours now. I think it's time I asked for help. I'm lear

how to timeout $doc = new DOMDocument()->load($url)
I am currently using this $doc->load($url) to fetch an rss feed.
If a feed takes long than

Automatic Webpage ??
I have a page www.mysite.com/test.php with a
<form>
<textarea name=&q

firefox wouldnt stream mp3 files completely from my php page
hi everyone,
I have a php file trying to read and stream mp3 files. It works fine in IE but my pr

foreach and array need help combining
Hi guys.

Here's the code

Code: array(
'tag' => 'code',<

How to have a log of all the status a VIM document had been ?
Hi guys,

I’m using SAP Invoice Management plugin and the /OPT/VIM_ANALYTICS transa

in php, link returns to the line
When I add a link in a php page, the link word returns to the line (as a
would do)

Examp

Querying info from one table based on info in another
Hi, I am currently trying to make a part for my user driven website where one user can subscribe to

Help with some dates
I have a list of dates in an array:

$mondays = array(
strtotime("October 12, 2009

Curly Bracket Delimeters.
I'd always believed that the starting and ending delimeters in preg_ functions had to be the same ch

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