Advertisement
Guest User

Untitled

a guest
Feb 26th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. class A
  4. {
  5. public:
  6. A(int n = 0)
  7. : m_n(n)
  8. {
  9. std::cout << 'd';
  10. }
  11.  
  12. A(const A& a)
  13. : m_n(a.m_n)
  14. {
  15. std::cout << 'c';
  16. }
  17.  
  18. private:
  19. int m_n;
  20. };
  21.  
  22. void f(const A &a1, const A &a2 = A())
  23. {
  24. }
  25.  
  26. int main()
  27. {
  28. A a(2), b;
  29. const A c(a), &d = c, e = b;
  30. b = d;
  31. A *p = new A(c), *q = &a;
  32. static_cast<void>(q);
  33. delete p;
  34. f(3);
  35. std::cout << std::endl;
  36.  
  37. return 0;
  38. }
  39.  
  40. explicit A(int n = 0)
  41.  
  42. explicit A(int n = 0)
  43.  
  44. struct X {
  45. X(int);
  46. X(const char*, int =0);
  47. X(int, int);
  48. };
  49.  
  50. void f(X arg) {
  51. X a = 1; // a = X(1)
  52. X b = "Jessie"; // b = X("Jessie",0)
  53. a = 2; // a = X(2)
  54. f(3); // f(X(3))
  55. f({1, 2}); // f(X(1,2))
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement