Horje
c++ vector of class objects Code Example
c++ vector of class objects
#include <iostream>
#include <vector>
using namespace std;

class Site {
public:
    int i;
};

int main() {
    vector<Site> listofsites;
    Site *s1 = new Site;
    s1->i = 7;
    Site *s2 = new Site;
    s2->i = 9;
    listofsites.push_back(*s1);
    listofsites.push_back(*s2);
    vector<Site>::iterator it;
    for (it = listofsites.begin(); it != listofsites.end(); ++it) {
        cout << it->i;
    }
    return 0;
}




Cpp

Related
forward declaration c++ Code Example forward declaration c++ Code Example
selection sort c++ algorithm Code Example selection sort c++ algorithm Code Example
what does the modularity mean in c++ Code Example what does the modularity mean in c++ Code Example
how to check sqrt of number is integer c++ Code Example how to check sqrt of number is integer c++ Code Example
max function in c++ Code Example max function in c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8