#include<iostream.h>
#include<conio.h>

class Basis
{
private :
int alpha; //sementara belum terpakai
int bravo; //sementara belum terpakai
public :
void info_basis()
{
cout<<” Info_basis() dijalankan …”<<endl;
cout<<” \n”;
}
};
class Turunan : public Basis
{
public :
void info_turunan()
{
cout<<” Info_turunan() dijalankan …”<<endl;
}
};
void main()
{
clrscr();

Turunan anak;

anak.info_basis(); //mewarisi kelas basis
anak.info_turunan();
}

===========================================================================*

#include<iostream.h>
#include<conio.h>

class Basis
{
protected:
int alpha;
int bravo;
public :
void info_basis()
{
cout<<” Info_basis() dijalankan …”<<endl;
}
};
class Turunan : public Basis
{
public :
void inisialisasi(int x,int y)
{ alpha = x; bravo = y;}
void info_turunan()
{
cout<<” Info_turunan() dijalankan …”<<endl;
cout<<”\n”;
cout<<” ALPHA = “<<alpha<<”\n\n”
<<” BRAVO = “<<bravo<<endl;
}
};
void main()
{
clrscr();

Turunan anak;

anak.inisialisasi(7, 10); //alpha <- 7, bravo <- 10
anak.info_turunan();

}

============================================================================*

#include”iostream.h”
class makhluk
{
public:
void berkembang();
};
class hewan : public makhluk
{
public:
void bergerak();
};
class kuda : public hewan
{
public:
void berlari();
};
main()
{
makhluk mk;  hewan hw;  kuda kd;
cout<<endl<<” Sifat-sifat dari Makhluk adalah : “<<endl;
mk.berkembang();
cout<<endl<<” Sifat-sifat dari Hewan adalah : “<<endl;
hw.berkembang();  hw.bergerak();
cout<<endl<<” Sifat-sifat dari Kuda adalah : “<<endl;
mk.berkembang();  hw.bergerak();  kd.berlari();
}
void makhluk::berkembang()
{
cout<<” Berkembang biak”<<endl;
}
void hewan::bergerak()
{
cout<<” Bergerak berpindah tempat”<<endl;
}
void kuda::berlari()

====================================================================*

#include”iostream.h”

class kuda
{
public :
void berlari()
{
cout<<” > Berlarinya sangat cepat”<<endl;
}
};
class burung
{
public:
void terbang()
{
cout<<” > Terbang menembus awan”<<endl;
}
};
class pegasus: public kuda, public burung
{
public:
void lariterbang()
{
cout<<” > Bersayap, lari dan dapat terbang ke angkasa”<<endl;
}
};
main()
{
pegasus pg;
cout<<”Sifat dari PEGASUS yaitu : “<<endl;
pg.berlari();
pg.terbang();
pg.lariterbang();
}

=====================================================================================*

#include”iostream.h”
class hewan
{
public:
void bergerak()
{
cout<<” # Bergerak berpindah tempat”<<endl;
}
};
class kuda: virtual public hewan
{
public :
void berlari()
{
cout<<” # Berlarinya sangat cepat”<<endl;
}
};
class burung: virtual public hewan
{
public:
void terbang()
{
cout<<” # Terbang menembus awan”<<endl;
}
};
class pegasus: public kuda, public burung
{
public:
void lariterbang()
{
cout<<” # Bersayap, lari dan dapat terbang ke angkasa”<<endl;
}
};
main()
{
pegasus pg;
cout<<”>> Sifat dari PEGASUS << “<<endl;
cout<<”========================”<<endl;
pg.bergerak();  pg.berlari();  pg.terbang();  pg.lariterbang();
}

=================================================================================*

#include”iostream.h”
#include”conio.h”
#include”string.h”
class Kendaraan
{
private:
char nama[15];

public:
Kendaraan(char *nama_kendaraan = “T1AS”)
{
strcpy(nama, nama_kendaraan);
cout<<” Hidupkan mesin kendaraan anda …”<<endl;
}
~Kendaraan()
{
cout<<” Matikan mesin kendaraan anda …”<<endl;
}
void info_kendaraan()
{
cout<<nama<<” Sedang berjalan …”<<endl;
}
};
class Mercy : public Kendaraan
{
public:
Mercy(char *nama_mercy) : Kendaraan(nama_mercy)
{
cout<<” Hidupkan mesin mobil merah …”<<endl;
}
~Mercy()
{
cout<<” Matikan mesin mobil merah itu …”<<endl;
}
};
void main()
{
clrscr();
Mercy mewah(” Mobil Yang Mewah”);
mewah.info_kendaraan();
cout<<” Akhir dari permulaaan()…”<<endl;
}

=========================================================================*

Sorting @pacsal

June 29, 2008

uses wincrt;
const
L: array [1..6] of integer = (07, 08, 01, 02, 04, 10);
pass:integer= 0;
nilai_diingat: integer = 0;
i:integer= 0;
label 1;

begin
for pass:= 1 to 5 do begin
nilai_diingat:= L[pass+1];
writeln(‘Nilai di ingat=’, nilai_dingat);

for i:=pass downto 1 do begin
writeln(‘test’);
if nilai_diingat< L[i] then begin
writeln(‘Sebelum digeser ‘, ‘L[i+1]=’, L[i+1], ‘ ‘, ‘L[i]=’, L[i]);
L[i+1]:=L[i];
writeln(‘Sesudah digeser ‘, ‘L[i+1]=’, L[i+1], ‘ ‘, ‘L[i]=’, L[i]);
L[i+1]:=L[i];
end else begin
{posisi sudah benar keluar dari loop}
L[i+1]:=nilai_diingat;
goto 1;
end;
end;
1:
end;
for i:=1 to 6 do begin
writeln(L[i]);
end;

end.

Musics for me.

June 23, 2008

There are many kinds of genre music i known has powerfull to bring up more peoples can dancing very nice. Hiphop was made and used almost of black rassicm. I feel too its can be every muscle in my body dancing following music. Especially when i think should free my mind from every problems. Music can be changing peoples to handling they problems. Entertainment forever for everyone in the world. Messenger in different way to expressions many kinds of interuption or feels. Everyone can be touching with Music, Moving around to get happiness in the deep of heart. Work with passion inclued Music is most of dreams everyone such as DJ’s in crowded they are able to make crowded happiness with musics. A Pete Tong is A DJ’s International Class and reffering research in England Magazine he’s DJ’s with Biggest Income in the world. Indonesia has a DJ’s famous too like DJ’s Riri as Spinach’s DJ School owner located in Kemang – South of Jakarta. Development Musics in Indonesia is growing rapidly prove with most of new comers in stage music Indonesia. The Best of Single Hits from new comers it’s very crucial to attracts more peoples listening they musics.

Just shocked.

June 23, 2008

Sometimes i just shocked with policies in my office especially in division where i work now. i now begining to new prospect for support my dream in the future. must be stronger to handling problems whatever that i must know what can i do to fight with it. Hoping with doing and pray make its perfect come true.by the way about my nearby plans is having a laptop to increase and improve skills. and it’s can be make me different person with another. Can anyone help me to do it ? I wish a laptop to designing and programming. Work with passion is dream in every people in the world, work without under pressure handling problems with smile. How they can do that ? cause they’re work with passionate. Everything they did was great in deep of heart and helpful to be success.

Blowout in motorcycle.

June 23, 2008

Hi..Morning reader.

Today i getting something can make me sad and angry. wake up at 06:00am in the morning friday, i was shock with blowout in motorcycle.i trying to remember whats happened in yesterday night. i’m across way where nail was spreads. imagine it was a street in front of my building office. Why i say that ? cause it was happened in someone too. i hope this isn’t re-happens.

The Weather in evening at 22 May 2008 is very cool with clouds. I still in my office desk hoping miracle in my life. it was planned in years ago. I feels sadness without someone who can entering my heart. I didn’t known about my problems with girls and problems in the future. I want to someone who can give me advices especially for me to take someone who can complete my missing pieces. Time shown at 20.50 pm i should prepare to take go home. I have made plan one of it was happened in my life. Thanks God. Nothing perfectly except ALLAH SWT.

At 22-05-2008

June 23, 2008

Today..
At 16.00 Wib, I drunk a coffee cup. I wish a Laptop to sharpen my skill in Design, especially in Website Design.
but, maybe not this time not this month cause i have problem with my financial plan.I seems many kinds of Laptop to do buy later. And now i cultivated something in there for helpful my dream. Do you know what i wish ? I’m want to be a Profesionalism with international class in my focus [Website Design].

Example : Simple Virtual Function.

Declared By :

Rizky a.k.a Reul, Mas Willy as Administrator of (http://forum.linux.or.id/) and link source code-nya lupa.

#include <iostream.h>

// using namespace std;

class BaseClass { // mendefinisikan class baru/INDUK yaitu BaseClass

public: // mendefinisikan bahwa public artinya bisa di akses oleh semua class

int i;

BaseClass(int x) {

i = x;

}

virtual void myFunction() /* mendefinisikan bahwa kita memakai VIRTUAL, artinya fungsi ini bisa di implementasikan ke class anak yaitu “DerivedClass1 dan DerivedClass2 */

{

cout << “Using BaseClass version of myFunction(): “; //menampilkan kata2 tsb

cout << i << ‘\n’; // menampilkan hasil dari i

}

};

class DerivedClass1 : public BaseClass { /* mendefiniskan bahwa class DerivedClass1 merupakan TURUNAN dari class BaseClass

*/

public: // mendefinisikan bahwa public artinya bisa di akses oleh semua class

DerivedClass1(int x) : BaseClass(x) {} /* artinya DerivedClass1 mengambil nilai x dari BaseClass dan telah di definisikan pula oleh BaseClass BaseClass(int x) { i = x; } */

void myFunction() // memanggil fungsi yaitu myFunction yang telah di definisikan VIRTUAL

{

cout << “Using DerivedClass1’s version of myFunction(): “; //menampilkan kata2 tsb

cout << i*i << ‘\n’; // menampilkan hasil dari i

}

};

class DerivedClass2 : public BaseClass {

/* mendefiniskan bahwa class DerivedClass2 merupakan TURUNAN dari class BaseClass

*/

public: // mendefinisikan bahwa public artinya bisa di akses oleh semua class

DerivedClass2(int x) : BaseClass(x) {} /* artinya DerivedClass2 mengambil nilai x dari BaseClass dan telah di definisikan pula oleh BaseClass BaseClass(int x) { i = x; } */

void myFunction() // memanggil fungsi yaitu myFunction yang telah di definisikan VIRTUAL

{

cout << “Using DerivedClass2’s version of myFunction(): “; //menampilkan kata2 tsb

cout << i+i << ‘\n’; //menampilkan hasil dari i

}

};

int main()

{

BaseClass *p; //mendefinisikan pointer *p sebagai BaseClass

BaseClass ob(10); //mengisi nilai BaseClass dengan nama ob menjadi 10

DerivedClass1 derivedObject1(10); // mengisi nilai DerivedClass1 dengan nama derivedObject1 menjadi 10 yang telah di definisikan dengan variable i */

DerivedClass2 derivedObject2(10); //Dan mengisi nilai DerivedClass2 dengan nama derivedObject2 menjadi 10 yang telah di definisikan dengan variable i */

p = &ob; // mendefinisikan bahwa pointer *p beralamatkan isi dari ob yaitu 10

p->myFunction(); // use BaseClass’s myFunction()

/* memanggil fungsi BaseClass dengan nilai p=10

*/

p = &derivedObject1; // mendefinisikan bahwa pointer *p beralamatkan isi dari derivedObject1 yaitu 10

p->myFunction(); // use DerivedClass1’s myFunction()

/* memanggil fungsi DerivedClass1 yang telah di definisikan oleh derivedObject1 dengan nilai p=10

*/

p = &derivedObject2; // mendefinisikan bahwa pointer *p beralamatkan isi dari derivedObject1 yaitu 10

p->myFunction(); // use DerivedClass2’s myFunction()

/* memanggil fungsi DerivedClass2 yang telah di definisikan oleh derivedObject2 dengan nilai p=10

*/

return 0;

}

Notes for u :

=> Virtual berarti nanti bisa DITIMPA oleh class turunan.

=> C++ khan OOP, jadi kita bisa punya sebuah class yang nanti BISA DI TURUNKAN oleh class lain

=> nah kalo pada class INDUK kita definisikan virtual, maka class ANAK bisa menimpa implementasi

di class INDUK

=> PRIVATE hanya bisa diakses oleh class yang sama

=> kalo PUBLIC bisa diakses semua class

=> class DerivedClass1 : public BaseClass [ artinya mendefiniskan bahwa class DerivedClass1 merupakan turunan dari class BaseClass]

Was Written by:

Rizky a.k.a Reul

00.09am, Tuesday 10 June 2008.

<====[ Exploring Your iDea ]====>
www.m-r1zq.co.nr | www.thereullc.blogspot.com

Latihan :

1.Buatlah program dengan menggunakan kelas dengan fungsi yang di definisikan di dalam kelas,dengan tampilan sbb:

NIM             : 1234
Nama            : Andi
Jurusan         : Teknik Informatika
Alamat          : Meruya Selatan

2.Buatlah program dengan menggunakan kelas dengan fungsi yang di definisikan di luar kelas,dengan tampilan sbb:

Merek           : Honda GL Pro
Tahun           : 2007
No Polisi       : B1669OK
Warna           : Hitam

===============================================================

The Answer below and was cr4ck3d  d(^_^)b  thanks to Tya dkk.

===============================================================

Compiler : G++ Ubuntu Linux Feisty Fawn 7.04

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

#include <iostream.h>

#include <string.h>

class mahasiswa

{

private:

int id;

char nama[80], jurusan [50], alamat [100];

public:

void tampilkan(void)

{

cout<<”Nim : “<<id<<endl;

cout<<”Nama : “<<nama<<endl;

cout<<”Jurusan : “<<jurusan<<endl;

cout<<”Alamat : “<<alamat<<endl;

}

void set(int idn, char *n, char *j, char *a)

{

id = idn;

strcpy(nama,n);

strcpy(jurusan,j);

strcpy(alamat,a);

}

};

int main()

{

mahasiswa saya;

saya.set(1234,”Andi”,”Teknik Informatika”,”Meruya Selatan”);

saya.tampilkan();

return 0;

}

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

#include <iostream.h>

#include <string.h>

class motor

{

private:

char merek [80], tahun [5], no_pol [15], warna [10];

public:

void tampilkan();

void set(char *m,char *t, char *n, char *w);

};

int main()

{

motor saya;

saya.set(“Honda GL Pro”, “2007″, “B1669OK”, “Hitam” );

saya.tampilkan();

}

void motor :: tampilkan(void)

{

cout<<”Merek : “<<merek<<endl;

cout<<”Tahun : “<<tahun<<endl;

cout<<”No Polisi : “<<no_pol<<endl;

cout<<”Warna : “<<warna<<endl;

}

void motor :: set(char *m, char *t, char *n, char*w )

{

strcpy(merek,m);

strcpy (tahun,t);

strcpy (no_pol,n);

strcpy (warna,w);

}

Membahas tentang kosep [OOP] Objek Oriented Programming dan Fungsi dalam C++.

#include<iostream.h>
float luaspersegipanjang(float panjang,float lebar);
void main()
{
float p,l;
cout<<”Masukan Panjang = “;
cin>>p;
cout<<”Masukan Lebar = “;
cin>>l;
cout<<”Nilai luar persegi panjang”<<luaspersegipanjang(p,l);
}
float luaspersegipanjang(float panjang,float lebar)
{
float luas;
luas=panjang*lebar;
return luas;
}

=============================================*

#include<iostream.h>
float keliling(float r)
{
float phi=3.14;
return (2*phi*r);
}

void main()
{
float r;
cout<<”Masukan Jari-jari ; “;
cin>>r;
cout<<”Keliling Lingkaran=”<<keliling(r);
}

===============================================================*

#include <iostream.h>
#include <string.h>
class penduduk
{
private:
int id;
char nama[80];
public:
void tampilkan(void)
{
cout<<”No. KTP : “<<id<<endl;
cout<<”Nama    : “<<nama<<endl;
}
void set(int idn, char *n)
{
id = idn;
strcpy(nama,n);
}
};

void main()
{
penduduk saya;
saya.set(1234,”Andi”);
saya.tampilkan();
}

===============================================================*

#include <iostream.h>
#include <string.h>
class penduduk
{
private:
int id;
char nama[80];
public:
void tampilkan();
void set(int idn, char *n);
};

void main()
{
penduduk saya;
saya.set(1234,”Andi”);
saya.tampilkan();
}

void penduduk :: tampilkan(void)
{
cout<<”No. KTP : “<<id<<endl;
cout<<”Nama    : “<<nama<<endl;
}
void penduduk :: set(int idn, char *n)
{
id = idn;
strcpy(nama,n);
}

===============================================================*