在c ++中传递具有多个条目的结构体 [英] Passing a struct with multiple entries in c++

查看:174
本文介绍了在c ++中传递具有多个条目的结构体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图传递一个坐标,它被定义为具有2个整数参数的struct(struct叫做coord),如下:

I am trying to pass a coordinate, which is defined as struct with 2 integer parameters (the struct is called coord) the following way:

UpdateB({0,0}); 

其中输入参数的类型是coord(即在上面的语句中我试图传递一个坐标 0,0 )。 UpdateB 是一些函数。我收到一个错误,任何想法什么
的问题可能是

where the input argument is of type coord (i.e. in the above statement I am trying to pass a coordinate 0,0). UpdateB is some function. I am getting an error, any ideas what the problem could be?

推荐答案

做一个构造函数接受两个argumnets。
通过如下:

Make a constructor accepting two argumnets. Pass it as follows:

MyFunc(Point2d(0,0));

这篇关于在c ++中传递具有多个条目的结构体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆