I'm trying to make my own string class in c++11 but I have some problems. comparing my class to the std::string class, I can't figute out how to use the
std::string.at(int) = 'a'; method/overloading.
I've created the at(int) method in my own class:
int at(int index)
{
if(index <0 || index > size-1) {throw std::out_of_range("Error, index out of range");}
return data[index];
}
and it workd well if I only use:
MyString.at(2);
In the main file:
MyString = "Hello world!"; //Works fine!
MyString.at(2)='a'; //Gives, Error: expressino must be a modifiable Ivalue.
Any help with this would be great, Thanks!
index > size-1can be written more idiomatically asindex >= size.