Original Post
🔒 Locked
array
Advertisement
Yes, if B is a friend of A or if you create a function that returns the array (or a const reference to it).
Colin Jeanne | Invader''s Realm
Colin Jeanne | Invader''s Realm
You didn''t specify a language, so I''ll give it to you in C# :-)
Hope that helps,
Joel Martinez
http://www.codecube.net/
public class A
{
private string[] _myArray;
//... other init code
public string[] GetArray()
{
return this._myArray;
}
}
public class B
{
public void DoSomethingWithA(A refToA)
{
string[] localArray = refToA.GetArray();
//Do something with the localArray now
}
}
Hope that helps,
Joel Martinez
http://www.codecube.net/
alternatively, A could be coded to use a public property accessor instead of a public method to return the private array
Joel Martinez
http://www.codecube.net/
public class A
{
private string[] _myArray;
//... other init code
public string[] MyArray
{
get {return this._myArray;}
}
}
public class B
{
public void DoSomethingWithA(A refToA)
{
string[] localArray = refToA.MyArray;
//Do something with the localArray now
}
}
Joel Martinez
http://www.codecube.net/
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement