about c++ conversion : no known conversion for argument 1 from ‘[some_class]' to ‘[some_class]&’

后端 未结 2 1575
一个人的身影
一个人的身影 2021-02-01 01:31

I\'m working on C++, and had an error that I didn\'t know the exact reason. I\'ve found the solution, but still want to know why.

    class Base
    {
        p         


        
2条回答
  •  借酒劲吻你
    2021-02-01 02:24

    In the first case you attempt to pass a (non-const)reference to a temporary as argument to a function which is not possible. In the second case you pass a reference to an existing object which is perfectly valid.

提交回复
热议问题