Advertisement
xathrya

Kuis Kelas

Apr 17th, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3.  
  4. class kelasku
  5. {
  6.    int x;
  7. public:
  8.    kelasku() { x = 135; }
  9.    cetak() { std::cout << x << std::endl; }
  10. };
  11.  
  12. int main()
  13. {
  14.    kelasku obj1;
  15.    kelasku *obj2;
  16.  
  17.    obj2 = (kelasku*) malloc(sizeof(kelasku));
  18.  
  19.    obj1.cetak();
  20.    obj2->cetak();
  21.  
  22.    return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement