Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. class Foo {
  2.  
  3. public:
  4.  
  5.     Foo(double nw): x(nw) { };
  6.  
  7.     virtual ~Foo() = default;
  8.  
  9.     inline operator double() noexcept { return x; }
  10.  
  11. private:
  12.     double x = double();
  13.  
  14. };
  15.  
  16. class Bar : public Foo {
  17.  
  18.     using Foo::Foo;
  19.  
  20. public:
  21.     ~Bar() = default;
  22.  
  23.     inline operator double() noexcept { return Foo::operator double(); }
  24. };
  25.  
  26.  
  27. int _tmain(int argc, _TCHAR* argv[])
  28. {
  29.     Bar d(4.2);
  30.     std::cout << d;
  31.     _getch();
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement