Created
March 29, 2013 23:23
-
-
Save imduffy15/5274348 to your computer and use it in GitHub Desktop.
Compile with:
g++ main.cpp Test.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <string> | |
| #include "Test.h" | |
| int main() { | |
| Test item = Test(); | |
| std::string hello = "Hello World"; | |
| item.setMessage(&hello); | |
| item.putMessage(); | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "Test.h" | |
| Test::Test() {} | |
| void Test::setMessage(std::string* message) { | |
| this->message = message; | |
| } | |
| void Test::putMessage() { | |
| std::cout << *this->message; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| class Test { | |
| private: | |
| std::string* message; | |
| public: | |
| Test(); | |
| void setMessage(std::string* message); | |
| void putMessage(); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment