fork download
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. class test{
  6. public:
  7. test(int a = 1) : a_(a) {}
  8. int get() const { return a_; }
  9. private:
  10. int a_;
  11. };
  12.  
  13. void * heap_alloc(size_t nbytes) { return malloc(nbytes); }
  14.  
  15. int main() {
  16. cout<<sizeof(test)<<endl;
  17. test * ptr = reinterpret_cast< test * >(heap_alloc(sizeof(test)));
  18. cout<<ptr->get()<<endl;
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0.01s 5300KB
stdin
Standard input is empty
stdout
4
0