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
49
Other forums
problem with query error
First Thanks to those who helped me on my previous posts, and the following code i'm using is not mi
Escaped characters
I have a script that allows you to post news to the home page of my site. Along with the news is the
Multiple server callbacks (NOT POSTBACKS)
Hello,
I have 2 different javascript client side functions that are on timers. When the timers elap
Help Ordering Arrays
Hi, I have 3 arrays as shown below.
Code: $users = $this->get_latest_users();
$flir
Undefined Index Notice In Internet Explorer Only
I am getting the following notice:
QuoteNotice: Undefined index: jrox in /home/ycsn/public_h
Print out contents of to Excel
I have got this script that gathers all the data that I need but I need it to send it to excel inste
login and redirect
hello! can someone help me.. can you give me an idea.. I want to make a login page and redirects it
Something like an INI editor or a DelimitedText-Editor
Hi all,
Am very, very, very new to PHP and not sure if I should be posting this to a Javascri
please, need help coding this voting for your favorite car polling system.
hi, my code needs a lot of work, but i want to be able to let users vote on their favorite car, upda
Problem writing URL into database
How would I write this into the database?
<?php echo "http://".$_SERVER['SER