fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <memory.h>
  4. #include <new>
  5.  
  6. class Base
  7. {
  8. public:
  9. virtual void Bar() { printf("bar()"); }
  10. };
  11.  
  12. class Test : public Base
  13. {
  14. public:
  15. Test() : m_Name("") {}
  16. Test(const char *string) : m_Name(string) { }
  17.  
  18. const char *m_Name;
  19. };
  20.  
  21. int main()
  22. {
  23. const char *hello = "Hello world";
  24. Test * test = new Test(hello);
  25. Test two;
  26. new (&two) Test(hello);
  27.  
  28. printf("Comparison: %d", memcmp(test, &two, sizeof(Test)));
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
Comparison: 0