Thursday, November 3, 2011
Contoh program konstruktor ke 2 Pada c++
#include<iostream.h>
#include<conio.h>
#include<string.h>
class Buku
{
private:
char judul[35];
char pengarang[25];
char jumlah;
public:
Buku (char*judul,char*pengarang,int jumlah);
void info();
};
void main()
{
clrscr();//Hapus layar
Buku novel ("Siaga Merah","Alistair MacLean",3);
novel.info();
}
//Devinisi fungsi anggota
Buku::Buku(char*judul,char*pengarang,int jumlah)
{
strcpy(Buku::judul,judul);
strcpy(Buku::pengarang,pengarang);
Buku::jumlah=jumlah;
}
void Buku::info()
{
cout<<"Judul :"<<judul<<endl;
cout<<"Pengarang :"<<pengarang<<endl;
cout<<"Jumlah buku :"<<jumlah<<endl;
}
#include<conio.h>
#include<string.h>
class Buku
{
private:
char judul[35];
char pengarang[25];
char jumlah;
public:
Buku (char*judul,char*pengarang,int jumlah);
void info();
};
void main()
{
clrscr();//Hapus layar
Buku novel ("Siaga Merah","Alistair MacLean",3);
novel.info();
}
//Devinisi fungsi anggota
Buku::Buku(char*judul,char*pengarang,int jumlah)
{
strcpy(Buku::judul,judul);
strcpy(Buku::pengarang,pengarang);
Buku::jumlah=jumlah;
}
void Buku::info()
{
cout<<"Judul :"<<judul<<endl;
cout<<"Pengarang :"<<pengarang<<endl;
cout<<"Jumlah buku :"<<jumlah<<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