Skip to content

Instantly share code, notes, and snippets.

@Ben1980
Last active February 14, 2019 20:59
Show Gist options
  • Select an option

  • Save Ben1980/19d00cc972335a66e082dab8fe345bc8 to your computer and use it in GitHub Desktop.

Select an option

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