Advertisement
SRD

delegating_constructors

SRD
May 27th, 2020
1,288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. Node::Node()
  2. {
  3.     do_something();
  4. }
  5.  
  6. /* What is the proper syntax here to call the above constructor, and have initialization lists. */
  7. Node::Node(const unsigned int idx, std::shared_ptr<ioctl_node_t> io) : Node(), index(idx), node(io)
  8. {  
  9.     do_more_stuff();
  10. }  
  11.  
  12. /* The above results in the following error.
  13. node.cc:26:106: error: mem-initializer for ‘Node::index’ follows constructor delegation
  14.  Node::Node(const unsigned int idx, std::shared_ptr<ioctl_node_t> n) : Node(), index(idx), node(n)
  15. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement