Added operator= integer operator.
This commit is contained in:
parent
9d62a09140
commit
8648ab3152
10
MString.cpp
10
MString.cpp
@ -139,7 +139,15 @@ namespace coreutils {
|
||||
cursor = this->data;
|
||||
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);
|
||||
|
@ -129,6 +129,12 @@ namespace coreutils {
|
||||
|
||||
MString &operator=(double value);
|
||||
|
||||
///
|
||||
/// Assignment operator for saving an integer value..
|
||||
///
|
||||
|
||||
MString &operator=(int value);
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
|
@ -88,7 +88,12 @@ int main(int argc, char **argv) {
|
||||
coreutils::MString test26;
|
||||
double test27 = 4.0f;
|
||||
test26 = test27;
|
||||
std::cout << "float: " << test26 << std::endl;
|
||||
std::cout << "float: " << test26 << std::endl;
|
||||
|
||||
coreutils::MString test28;
|
||||
int test29 = 402;
|
||||
test28 = test29;
|
||||
std::cout << "int: " << test28 << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user