class Text
{
public :
char& operator[](int pos) const
{return text[pos];}
char* get() const
{return text;}
private:
char* text = "hello";
};
int main()
{
Text a;
char * x = &a[0];
*x = 's';
cout << a.get() << endl;
}
I was following Scott Meyers Effective C++ book, there was a class that I had to implement myself, so I tried implementing it my self, but this program keeps crashing.