c++ passing arguments by reference and pointer

后端 未结 5 1917
-上瘾入骨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:46

    Function foo can modify arg in cases 2 and 3. In first cases compiler could optimize copy creation, so it is very hard to compare cpu and memory usage.

提交回复
热议问题