Thursday, November 3, 2011
Contoh program konstruktor Pada c++
#include<iostream.h>
#include<conio.h>
class kompleks
{
private:
double re;//nilai real
double im;//nilai imajiner
public:
kompleks();//konstruktor
void info();
};
void main()
{
clrscr();//hapus layar
kompleks a;//mendefinisikan objek a
a.info();
kompleks b;//mendefinisikan objek b
b.info();
}
//definisi fungsi anggota kelas kompleks
kompleks::kompleks()
{
cout<<"konstruktor di jalankan......."<<endl;
re=5.2;
im=3.6;
}
void kompleks::info()
{
cout<<"\nBilangan kompleks:"<<endl;
cout<<"real ="<<re<<endl;
cout<<"imajiner ="<<im<<endl;
cout<<endl;
}
#include<conio.h>
class kompleks
{
private:
double re;//nilai real
double im;//nilai imajiner
public:
kompleks();//konstruktor
void info();
};
void main()
{
clrscr();//hapus layar
kompleks a;//mendefinisikan objek a
a.info();
kompleks b;//mendefinisikan objek b
b.info();
}
//definisi fungsi anggota kelas kompleks
kompleks::kompleks()
{
cout<<"konstruktor di jalankan......."<<endl;
re=5.2;
im=3.6;
}
void kompleks::info()
{
cout<<"\nBilangan kompleks:"<<endl;
cout<<"real ="<<re<<endl;
cout<<"imajiner ="<<im<<endl;
cout<<endl;
}
Subscribe to:
Post Comments
(
Atom
)
Pengunjung Ke :
Categories
- Android ( 3 )
- Anti Virus ( 2 )
- Audio n Video ( 3 )
- BBM ( 1 )
- Berita ( 7 )
- Blogging ( 42 )
- Facebook ( 9 )
- Internet ( 3 )
- Kata - kata ( 1 )
- Lenovo_A390 ( 2 )
- Linux ( 2 )
- Make mooney ( 4 )
- Microsoft Office ( 2 )
- sekolah_bahasa indo ( 2 )
- sekolah_IT_c++ ( 9 )
- sekolah_IT_css ( 11 )
- sekolah_IT_Database dan SI ( 2 )
- sekolah_IT_database(SQL) ( 2 )
- sekolah_IT_fisika ( 1 )
- sekolah_IT_html ( 17 )
- sekolah_IT_java ( 2 )
- sekolah_IT_photoshop ( 2 )
- sekolah_IT_php ( 20 )
- sekolah_IT_so/is ( 2 )
- Sekolah_kimia ( 2 )
- Software ( 14 )
- Software_Editing ( 3 )
- Tampilan Dekstop ( 6 )
- Tips n Trik ( 38 )
0 comments :
Post a Comment