Class segitiga


mari kita belajar membuat class segi tiga, saya pertama kali kenal class segi tiga waktu saya semester 1,
suatu hari ada tugas bikin class segi tiga menggunakan bahasa c++, lalu saya liat modul dan mulai cetak cetuk ngetik bikin program..
ini lah hasilnya class segi tiga yg sya buat

#include
#include
class SegiTiga {
friend ostream& operator<>(istream&,SegiTiga&);
public:
SegiTiga(){}
double luas() const;
private:
int a,t;
};
ostream& operator<<(ostream& out,const SegiTiga& j){
out << "Luas : " <>(istream& in,SegiTiga& j){
cout <> j.a;
cout <> j.t;
return in;
}
double SegiTiga::luas()const{
return ((a*t)/2.0);
}
void main(){
SegiTiga j;
cin >> j;
cout << j;
getch();
}

semoga bermanfaat

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: