Call function with default argument from .dll with c++

前端 未结 2 1430
春和景丽
春和景丽 2021-01-21 23:37

I have a function defined in the Header of my .dll

void calculo(vector A, vector B, double &Ans1, double jj);

in t

2条回答
  •  佛祖请我去吃肉
    2021-01-22 00:32

    Default arguments:

    Are only allowed in the parameter lists of function declarations

    If you don't want to default the argument in the header you could accomplish what you're trying to do by overloading the function:

    void calculo(const vector& A, const vector& B, double &Ans1, const double jj);
    void calculo(const vector& A, const vector& B, double &Ans1) { calculo(A, B, Ans1, 36.5); }
    

    As a bonus comment, please pass vectors by constant reference as passing by value incurs the potentially expensive copy cost.

提交回复
热议问题