struct a has int b, and pointer to struct as its elements. And program crashes without printing results.
struct a{
int b{5};
a* next=new a;
a(){
next->b=3;
}
};
int main(){
a a1;
cout<<a1.b<<endl;
cout<<(*(a1.next)).b<<endl;
return 0;
}
I expected output to be:
5
3