Skip to content

Instantly share code, notes, and snippets.

@jpalawaga
Created April 7, 2014 02:08
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 jpalawaga/10013887 to your computer and use it in GitHub Desktop.
Save jpalawaga/10013887 to your computer and use it in GitHub Desktop.
#include <iostream>
class myClass {
private:
int * test;
public:
myClass() {
test = new int(4);
}
int * getPtr() { return test; }
void printTest() { std::cout << "PRINTING: " << (*test) << std::endl; }
};
int main() {
myClass * a = new myClass;
a->printTest();
int * p = a->getPtr();
(*p) = 5;
std::cout << (*p) << std::endl;
a->printTest();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment