Is it possible to initialize in dynamic way using pointers but just after the struct definition?
Please at the example. I tried that but I get an exception when I try cout << a->val << endl;
#include "stdafx.h"
#include <iostream>
using namespace std;
struct A{
public:
int val = 0;
A(){}
}*a,b,c;
int _tmain(int argc, _TCHAR* argv[]){
cout << a->val << endl;//EXCEPTION
cout << b.val << endl;
int x;
cin >> x;
return 0;
}
ais a null pointer, which is why dereferencing it with->causes an exception.