Created
July 11, 2016 06:23
-
-
Save eiennohito/146a4b889fa7a97d3b4dbe7070ea080a to your computer and use it in GitHub Desktop.
This file contains 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 <vector> | |
#include <iostream> | |
using namespace std; | |
struct Report { | |
pair<string, string> stage1; | |
pair<double, string> stage2; | |
}; | |
class Stage { | |
Report report; //embed object here | |
public: | |
explicit Stage(const Report &report): report(report) {} | |
void setReport(const string & value, const string & resolution) { | |
report.stage1 = make_pair(value, resolution); | |
} | |
Report* getptr() { return &(this->report); } | |
}; | |
int main(int argc, char **argv) { | |
Report r; | |
vector<Stage *> v; | |
v.push_back(new Stage(r)); | |
(*v[0]).setReport("set", "set"); | |
cout << r.stage1.first << " " << r.stage1.second << endl; | |
cout << &r << " " << v[0]->getptr() << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment