Skip to content

Instantly share code, notes, and snippets.

@imduffy15
Created March 29, 2013 23:23
Show Gist options
  • Select an option

  • Save imduffy15/5274348 to your computer and use it in GitHub Desktop.

Select an option

Save imduffy15/5274348 to your computer and use it in GitHub Desktop.
Compile with: g++ main.cpp Test.cpp
#include <string>
#include "Test.h"
int main() {
Test item = Test();
std::string hello = "Hello World";
item.setMessage(&hello);
item.putMessage();
return 0;
}
#include "Test.h"
Test::Test() {}
void Test::setMessage(std::string* message) {
this->message = message;
}
void Test::putMessage() {
std::cout << *this->message;
}
#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