Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- struct Base {
- int av;
- };
- struct A : public Base {
- int bv;
- };
- struct database {
- vector <Base> basev;
- Base NBase;
- database () { NBase.av = 0; }
- Base& findb (int value) {
- for (int i = 0; i < basev.size (); ++i) {
- if (basev [i].av == value) return basev [i];
- }
- return NBase;
- }
- } db;
- int main( ) {
- Base der;
- der.av = 5;
- db.basev.push_back (der);
- Base found = db.findb (5);
- cout << found.av << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement