Skip to content

Instantly share code, notes, and snippets.

@fifilyu
Created Sep 7, 2016
Embed
What would you like to do?
jccg90.cpp
#include <cstdio>
#include <vector>
#include <memory>
#include <iostream>
using namespace std;
struct Info {
bool a;
double b;
};
typedef shared_ptr<Info> InfoPtr_t;
void getInfoList(vector<InfoPtr_t> & infoList) {
auto info = make_shared<Info>();
info->a = true;
//info->b = 1.1;
infoList.push_back(info);
}
int main() {
vector<InfoPtr_t> infoList;
getInfoList(infoList);
for (auto it : infoList)
cout << "a=" << it->a << " b=" << it->b << endl;
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment