Passing optional parameter by reference in c++

后端 未结 10 1836
天涯浪人
天涯浪人 2020-12-02 22:39

I\'m having a problem with optional function parameter in C++

What I\'m trying to do is to write function with optional parameter which is passed by reference, so th

10条回答
  •  一向
    一向 (楼主)
    2020-12-02 23:03

    You can do this crazy way:

    void foo(double &bar, double &foobar = (*(new double())))
    

    P.S. - I know its not pleasant but its the way. Also be sure not to leave memory leaks! :))

提交回复
热议问题