Pages

Sabtu, 16 April 2011

Simple Program Using the Type Class(Program Sederhana Menggunakan Jenis Class)

How do you think the Implementation Class In In C + +?

In my opinion, the application of a class in C + + really, really helped her special in the simplification of a problem relating to an object. Use of classes to help us in giving a name to an object that it will consist of several classes in an object that we make. Thus the class can be defined as something that has the data (properties) and function (method). And whose name is still an abstract class, so it means you have to do instantiation (the process of simplification) of that class, then instance (embodiment) of the class is also often called by the object that I've alluded to earlier beginning. For example, man is a class, then the instance / object of the human class is ipin, upin, shinta, lilies, Lolo, etc..


Below, a simple program example in the manufacture of class on c + +:
# include "iostream.h" / / Program-ID: Fendy 2KA01

Car class


{

char Model [30];
float price;
int mileage;



public:
void accept ()
{
court <<"\ n \ nMasukan Type of Car:"; cin>> model;
court <<"Enter Price Of Car Type:"; cin>> price;
court <<"Car Speed​​:"; cin>> mileage;
}
void display ()
{
court <<"\ nJenis Your Car:" <<model;
court <<"\ nHarga Your Car:" <<price;
court <<"\ nKecepatan Your Car:" <<mileage <<"KM / Hour";
}
};
int main ()
{
Car c [2];
c [0]. accept ();
c [0]. display ();
c [1]. accept ();
c [1]. display ();
return 0;
}

Output:


0 komentar:

Posting Komentar