how to store struct in vector c++ code example
Example 1: how to store a struct in vector in c++
struct subject
{
string name;
int marks;
int credits;
};
vector<subject> sub;
Example 2: cpp vector structure
#include <vector>
typedef struct test1 {
int a;
char b;
} TOTO;
std::vector<TOTO> _v;
_v.push_back((TOTO){10, 'a'});
_v[0].a = 101;