Skip to content

Instantly share code, notes, and snippets.

@eiennohito
Created July 11, 2016 06:23
Show Gist options
  • Save eiennohito/146a4b889fa7a97d3b4dbe7070ea080a to your computer and use it in GitHub Desktop.
Save eiennohito/146a4b889fa7a97d3b4dbe7070ea080a to your computer and use it in GitHub Desktop.
#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