Skip to content

Instantly share code, notes, and snippets.

@shaunlgs
Last active October 8, 2016 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaunlgs/2db05e4c29dd0e6c57bf0693146bd968 to your computer and use it in GitHub Desktop.
Save shaunlgs/2db05e4c29dd0e6c57bf0693146bd968 to your computer and use it in GitHub Desktop.
// Program 2.14
#include <iostream>
using namespace std;
int bil = 0;
class UJI
{
private:
int nilai;
public:
UJI(int v)
{
nilai = v;
cout << "\nCreating object with value: " << nilai ;
}
~UJI()
{
cout << "\nDestroying object with value :" << nilai;
}
void change()
{
nilai *= nilai;
}
};
void external()
{
UJI objek1(10), objek2(5);
objek1.change();
}
int main()
{
UJI objek1(3),objek2(7);
objek2.change();
external();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment