Apollo: 询问Apollo6.0一个语法问题

Created on 29 Oct 2020  ·  2Comments  ·  Source: ApolloAuto/apollo

在modules/perception/onboard/transform_wrapper/transform_wrapper.h文件中声明了一个函数,有三个形参,novatel2world_trans给了默认值。

  bool GetSensor2worldTrans(double timestamp,
                            Eigen::Affine3d* sensor2world_trans,
                            Eigen::Affine3d* novatel2world_trans = nullptr);

在modules/perception/onboard/transform_wrapper/transform_wrapper.cc 中实现函数,函数的形参,没有给默认值。

bool TransformWrapper::GetSensor2worldTrans(
    double timestamp, Eigen::Affine3d* sensor2world_trans,
    Eigen::Affine3d* novatel2world_trans) {......}

在modules/perception/onboard/component/trafficlights_perception_component.cc中
调用函数
ret = trans_wrapper->GetSensor2worldTrans(timestamp, &affine3d_trans);
传入的参数只有两个。

没发现有函数重载的情况。
有大佬可以帮忙解答一下,这个是啥语法点。咋没见过。

Most helpful comment

This is standard c++ syntax.

default argument already specified in class scope, then you can't set default value inside the class body. default_arguments

class C {
    void f(int i = 3);
    void g(int i, int j = 99);
    C(int arg); // non-default constructor
};
void C::f(int i = 3) {         // error: default argument already
}                              // specified in class scope

All 2 comments

This is standard c++ syntax.

default argument already specified in class scope, then you can't set default value inside the class body. default_arguments

class C {
    void f(int i = 3);
    void g(int i, int j = 99);
    C(int arg); // non-default constructor
};
void C::f(int i = 3) {         // error: default argument already
}                              // specified in class scope

@daohu527 Good answer.

@since2016 , I hope that the answer from @daohu527 resolved your question.

And I'm going to close this issue now. Please feel free to create a new issue if you have other questions. And our engineering team is glad to help.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ahuer2435 picture ahuer2435  ·  3Comments

c-xyli picture c-xyli  ·  3Comments

YaoQii picture YaoQii  ·  3Comments

BenBaek picture BenBaek  ·  3Comments

poutyface picture poutyface  ·  3Comments