Skip to content

Instantly share code, notes, and snippets.

@rahman541
Last active December 27, 2018 04:56
Show Gist options
  • Save rahman541/8dcefb75dd018093956c91bfa961670d to your computer and use it in GitHub Desktop.
Save rahman541/8dcefb75dd018093956c91bfa961670d to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
using namespace std;
// REF: https://www.quora.com/Why-use-of-pointer-make-the-c-c++-language-less-secure-How-hackers-can-take-advantage-of-it
class Example
{
private:
int a=10; //private variable
public:
int b=20; //public variable
};
int main()
{
Example exe;
int *ptr;
ptr=&exe.b; //ptr that stores the address of b
cout<<"Var b: "<< *(ptr) <<endl;
--ptr; //decrease the value by 1
cout<<"Var a: "<< *(ptr) <<endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment