忽略引用函数参数(Ignore reference function argument)

编程入门 行业动态 更新时间:2024-10-26 01:30:21
忽略引用函数参数(Ignore reference function argument)

我有这个签名的功能(我不能编辑它):

void foo(int a,int b, int& c);

我想打电话给它,但我不在乎获取c。 目前我这样做:

int temp; foo(5,4,temp); //temp never used again

我的解决方案似乎愚蠢。 忽略这个论点的标准方法是什么?

I have function with this signature (I can not edit it):

void foo(int a,int b, int& c);

I want to call it but I do not care about the getting c. Currently I do this:

int temp; foo(5,4,temp); //temp never used again

My solution seems dumb. What is the standard way to ignore this argument.

最满意答案

空无一人。

如果你的担心主要是用临时存在的一个包装函数来污染你的当前堆栈......就像:

void foo_wrapper(int a, int b) { int temp; foo(a, b, temp); }

应该就够了。

There is none.

If your concern is primarily one of polluting your current stack with the presence of temp, a wrapper function... like:

void foo_wrapper(int a, int b) { int temp; foo(a, b, temp); }

should suffice.

更多推荐

本文发布于:2023-08-06 21:50:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1457653.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   参数   Ignore   argument   function

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!