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

Regarding accessing SQL query issued by any user in Oracle 10g
Hi all,
i want to know the queries issued by various users accessing a database...

values not being entered into table
hi. I;ve created a form, so that when a user enters data into it, it gets added to a table in a data

How to generate a random array of integers subject to a certain constraint
I am writing a program that asks the user to enter an integer N and then generates a random array of

Character Sets/Collations Stuff
Can someone please give me a check list of things I must do to setup all the charset stuff for my ph

Sum of Values in an Array
This is probably really simple... but it's been years since I've written anything, so bare with me!<

mail() problem
Hi Guys,

I've set up a contact email form. It sends the information fine, but it sends it to

Call db table from any PHP file
Hi,

I want to be able to call a database table that will be setup in another file called init

WS-Security PL/SQL Forms
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Prod
PL/SQL Release 10.2.0.2.0 - P

error with opendir
when i do this

if ($handle = opendir($dir)) {
while (false !== ($file = readdir($han

Reading waves
Hi,

I am trying to find a way of finding the highs and lows on a graph line, the line points

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