[英]C++ array of objects. One element to access method of another element in array
I have array of objects 我有很多物体
MyClass MyArr[10];
In method of one element of array ( MyArr[j] )
I need to access to method of another element in this array ( MyArr[i].Method2(arg) )
. 在数组一个元素
( MyArr[j] )
方法中,我需要访问此数组中另一个元素( MyArr[i].Method2(arg) )
。
How I Can do this? 我该怎么做?
Access from one element of array to another element of array? 从数组的一个元素访问数组的另一个元素?
There's lots of ways. 有很多方法。 Some are:
一些是:
MyArr
a static variable of the MyClass
class MyArr
成为MyClass
类的静态变量 MyArr[i]
as a parameter to the method call on MyArr[j]
MyArr[i]
作为参数传递给MyArr[j]
上的方法调用 您可以将数组传递给每个对象,也可以找到值得尝试的链表
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.