Last active
December 27, 2018 04:56
-
-
Save rahman541/8dcefb75dd018093956c91bfa961670d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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