This is a piece of code from Gem5 simulator, I am trying to understand the doInit() method (line 17), is it initializing the storage variable (allocated as char array) with Storage object
1
2
3 class Storage{
4 private:
5 double data;
6 public:
7 Storage():
8 data(100)
9 {}
10 double get_data(){ return data;}
11 void set_data(double val){ data = val;}
12 };
13 class Scalar: public Storage{
14 private:
15 char storage[sizeof(Storage)];
16 public:
17 void doInit(){
18 new (storage) Storage();
19 }
20 Storage * data(){
21 return reinterpret_cast<Storage *>(storage);
22 }
23 };
24 int main(){
25 Scalar s;
26 s.doInit();
27
28
29 return 0;
30 }
~