Hello judyotham,
Thank you for using code tags.
As I understand this
1 2 3 4 5
|
class UlamProgram
{
public:
String name;
};
|
"name" is defined as a "public" variable. As such the whole program has access to it. As a public variable you could just as easily used a "struct" or "global variable" because this defeats the purpose of a "class".
On the other hand
1 2 3 4 5 6
|
class ULAM
{
private:
UlamProgram programs[10];
UlamScreen screen;
};
|
"programs" is a "private" variable to the class and only a member function of the class can access this variable.
The problem is not getting to "name", but needing a "get" function to access "programs" first. After that "name" is "public" and all you have to do is use its name.
Class "ULAM" should look something like:
1 2 3 4 5 6 7 8 9
|
class ULAM
{
public:
std::string GetName();
private:
UlamProgram programs[10];
UlamScreen screen;
};
|
Then the function would be like:
1 2 3 4
|
std::string ULAM::GetName(size_t index)
{
return programs[index].name;
}
|
I believe this should work, but I have not had a chance to test it yet.
Just a small thing you forgot, or missed, the semi-colon after the closing "}" of the class.
Hope that helps,
Andy