fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4.  
  5. class Foo {
  6. private:
  7. int a;
  8. Foo() {}
  9. public:
  10. void setA(int v) { a = v; }
  11. void printA() { cout << a << endl; }
  12. };
  13.  
  14. int main() {
  15. Foo* obj = (Foo*)malloc(sizeof(Foo));
  16. obj->setA(10);
  17. obj->printA();
  18. free(obj);
  19. return 0;
  20. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
10