I put some different structs that inherits from the same parent struct but when I try to access their members, compiler gives me an error. The code is this:
#include <bits/stdc++.h>
using namespace std;
struct A
{
int a=0;
};
struct B:A
{
int b=0;
};
struct C:A
{
int c=0;
};
int main()
{
vector<A> va;
B bb;
C cc;
va.push_back(bb);
va.push_back(cc);
cout<<va[0].b;
return 0;
}
The error is this:
'__gnu_cxx::__alloc_traits<std::allocator<A> >::value_type {aka struct A}' has no member named 'b'|
What could I do to solve this???