c++ passing arguments by reference and pointer

后端 未结 5 1915
-上瘾入骨i
-上瘾入骨i 2020-12-03 09:59

in c++

class bar
{
    int i;
    char b;
    float d;
};

void foo ( bar arg );
void foo ( bar &arg );
void foo ( bar *arg );

this i

5条回答
  •  星月不相逢
    2020-12-03 10:43

    If you consider that it's good practice to validate pointer parameters before using them then, yes, pointers introduce extra overhead since references don't require such testing.

提交回复
热议问题