Anda di halaman 1dari 15

Inisialisasi variable

Tipe Data
How to use typedef?
When does wrapping happen?
IF
STRUCTURE

POITER
TIP
===============================================================
!lways t"in# t"at t"e warnin$ %essa$es as error %essa$es
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&
! Class "as followin$ features'
- The capability to control access
- Constructor
- Destructor
- Data members (usually called as properties)
- Member functions (usually called as method)
- A Hidden, special pointer called this
() !pril *+(,
! Class has three levels of access, there are publi-. private. prote-ted
! stru-ture doesn/t "ave t"ree levels of a--ess. only publi- a--ess
Publi- a--ess %eans -an be a--essed by outside
Private a--ess %eans only -an be a--essed internal i%ple%entation of t"e -lass 0inner
wor#in$s1
Prote-ted a--ess %eans -an/t be a--essed fro% publi- view. %eans user of t"e -lass
doesn/t need to #now
Data abstra-tion is the hiding of internal implementations within the class from
outside view
Prote-ted level is a little harder to be explained
Ob2e-t is an instan-e of a -lass
Constru-tor doesnt have return value
! -lass -an "ave %ore t"an one -onstru-tor. but only one destru-tor
CODING !"CI#$
class mobil
{
public:
int warna;
mobil();
mobil(int warna);
void showColor();
void releaseShow();
private:
void showNomorMesin();
};
void mobil::mobil()
{
warna=0;
}
void mobil::mobil(int warna)
{
mobil::warna=warna;
}
void mobil::showColor()
{
print(!"#$N#:!);
i(warna==0)
print(!hitam!);
else
print(!putih!);
print(!%n!);
}
void mobil::showNomorMesin()
{
print(!&'S&S!);
}
void mobil::releaseShow()
{
showNomorMesin();
}
void main()
{
clrscr();
print(!# C#$%n!);
mobil mobil(;
mobil()showColor();
mobil mobil*(();
mobil*)showColor();
mobil*)releaseShow();
+etch();
}
Constru-tor di%alan&an sebelum ob%e& dihancur&an' di dalam constructor bias
dileta&&an baris program (ang menghapus memori (ang diguna&an ) variable *
variable (ang tida& dipa&ai+
Data %e%ber is variables which are used in a class, -he( have access levels li&e the
class access levels,
-ida& semua C language men(edia&an tipe data .ool' tergantung versin(a %uga
( 3ay *+(,
/ultiple Inheritance 01 dapat mela&u&an semua method public (ang dimili&i
indu&n(a
/embaca 2ile mengguna&an librar( fstream,h
3include 4fstream,h1 55 include librar(
ifstream in6 55in sebagai input file stream
in,open)7-#-,C889+6 55membu&a file target
if):in+; 55%i&a file tida& ditemu&an
while):in,eof)++ <;= 55la&u&an instru&si %i&a bu&an a&hir dari file
in,getline)buff'si>eof)buff++6 55 baca per line dan ditampung di dalam buff
in,close)+ 55 menutup file