asm_book/section_1/structs/this.cpp
Perry Kivolowitz d62f2e5de3 added this
2023-05-17 10:38:24 -05:00

28 lines
463 B
C++

#include <stdio.h>
class TestClass {
public:
void SetString(char * s);
char * GetString();
private:
char * _s = nullptr;
};
void TestClass::SetString(char * s) {
_s = s;
printf("String set to: %s\n", _s);
}
char * TestClass::GetString() {
return _s;
}
char * test_string = (char *) "Test String";
TestClass tc;
int main() {
tc.SetString(test_string);
printf("Stored string is: %s\n", tc.GetString());
return 0;
}