Skip to content

Instantly share code, notes, and snippets.

@Ben1980
Last active February 14, 2019 20:59
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 Ben1980/19d00cc972335a66e082dab8fe345bc8 to your computer and use it in GitHub Desktop.
Save Ben1980/19d00cc972335a66e082dab8fe345bc8 to your computer and use it in GitHub Desktop.
Problem with const pointers
class MyClass {
public:
int * getArray() const {
arr[0]++;
return arr;
}
void setFirstVal(int val) { arr[0] = val; }
private:
int * arr = new int[10];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment