Guest User

Untitled

a guest
Jun 18th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. class BaseClass
  2. {
  3. public:
  4. BaseClass( const std::string& name ) : m_name( name ) { }
  5.  
  6. const std::string& getName() const { return m_name; }
  7.  
  8. private:
  9.  
  10. const std::string m_name;
  11.  
  12. //...
  13.  
  14. };
  15.  
  16.  
  17. class DerivedClass : public BaseClass
  18. {
  19. public:
  20.  
  21. DerivedClass( const std::string& name ) : BaseClass( name ) { }
  22.  
  23. // ...
  24. };
  25.  
  26. class TestClass :
  27. {
  28. public:
  29. TestClass( int testValue ); //...
  30. };
  31.  
  32. class UniqueTestClass
  33. : public BaseClass
  34. , public TestClass
  35. {
  36. public:
  37. UniqueTestClass()
  38. : BaseClass( "UniqueTest" )
  39. , TestClass( 42 )
  40. { }
  41.  
  42. // ...
  43. };
  44.  
  45. class Foo
  46. {
  47. Foo(char* c, int i);
  48. };
  49.  
  50. void Bar(Foo foo);
  51.  
  52. Bar(Foo("hello", 5));
  53.  
  54. Foo foo;
  55. foo.Foo(); // compile error!
  56.  
  57. char buffer[sizeof(Foo)]; // a bit of memory
  58. Foo* foo = new(buffer) Foo(); // construct a Foo inside buffer
Add Comment
Please, Sign In to add comment