Added operator= integer operator.

This commit is contained in:
Brad Arant 2024-10-14 10:09:14 -07:00
parent 9d62a09140
commit 8648ab3152
3 changed files with 21 additions and 2 deletions

View File

@ -140,6 +140,14 @@ namespace coreutils {
return *this;
}
MString &MString::operator=(int value) {
std::string temp = std::format("{}", value);
setSize(temp.length());
memcpy(this->data, (char *)temp.data(), temp.length());
cursor = this->data;
return *this;
}
MString &MString::operator<<(const char *value) {
int temp = length;
int len = strlen(value);

View File

@ -129,6 +129,12 @@ namespace coreutils {
MString &operator=(double value);
///
/// Assignment operator for saving an integer value..
///
MString &operator=(int value);
///
///
///

View File

@ -90,6 +90,11 @@ int main(int argc, char **argv) {
test26 = test27;
std::cout << "float: " << test26 << std::endl;
coreutils::MString test28;
int test29 = 402;
test28 = test29;
std::cout << "int: " << test28 << std::endl;
return 0;
}