Last active
February 14, 2019 20:59
-
-
Save Ben1980/19d00cc972335a66e082dab8fe345bc8 to your computer and use it in GitHub Desktop.
Problem with const pointers
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
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