The code below produces the following compilation error:
nestedStruct.cpp:30: error: expected primary-expression before '.' token
nestedStruct.cpp:30: error: expected ';' before "B"
My actual purpose in this is to generate a "tree data structure."
Code:
#include<iostream>
using namespace std;
struct animals{
struct insects;
struct fish;
struct mammals;
};
struct insects{
char moths[40];
char beatles[40];
char crickets[40];
};
struct fish{
char bass[40];
char shark[40];
};
struct mammals{
char gopher[40];
char elephant[40];
};
int main(){
animals A;
animals.insects B;
return 0;
}