fork(3) download
  1. #include <iostream>
  2.  
  3. using std::cout;
  4. using std::endl;
  5.  
  6. class A{
  7. public:
  8. A(){
  9. cout << "parameterless" << endl;
  10. }
  11.  
  12. A(const char *str){
  13. cout << "Parameter is " << str <<endl;
  14. }
  15. };
  16.  
  17. class B{
  18. A _argless;
  19. A _withArg;
  20.  
  21. public:
  22. // note that you need not call argument-less constructor explicitly.
  23. B(): _withArg("42"){
  24. }
  25. };
  26.  
  27. int main(){
  28. B b;
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
parameterless
Parameter is 42