Basic program using class

Posted by Didi Setyapramana On 10:01 PM 0 komentar


#include <cstdlib>
#include <iostream>

using namespace std;

class klass {
    int x, y;
  public:
    void nilai (int,int);
    int area (void) {return (x*y);}
};
void klass::nilai (int a, int b) {
  x = a;
  y = b;
}
int main () {
  klass rect;
  rect.nilai (3,4);
  cout << "Area: " << rect.area()<<endl;

    system("PAUSE");
    return EXIT_SUCCESS;
}

Categories: ,

0 Response for the "Basic program using class"

Post a Comment