calling a member function of different class from another class

后端 未结 2 1809
花落未央
花落未央 2021-01-03 09:45

I have two classes A and B. The control is inside one of the member functions of class A. The member function calculates a result and i now want to send this value to one of

2条回答
  •  天命终不由人
    2021-01-03 09:58

    After seeing your comment:

    The compiler throws "No matching function call B::B()"

    That means, there is no default constructor for class B. In your implementation, B`s constructor must be taking parameter.

    So either you add a default constructor to your class, or you pass the argument to your constructor when creating an instance of it.

提交回复
热议问题