1. Please use code tags when posting code, to make it readable:
http://www.cplusplus.com/articles/z13hAqkS/
2. This line does nothing:
myclasseB.Inputs[i];
What did you intend it to do?
3. You state that the array in class A is public. I assume you mean that you've declared it like this:
1 2 3 4 5
|
class ClassA
{
public:
std::array<QString,25>;
}
|
Putting aside the question of whether it's a good idea to make it a public data member, this means that any code that has access to the object of type A, can directly access that data member. So, for example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
ClassA myClasseA;
// Give Class B a public Inputs array data member as well
class ClassB
{
public:
std::array<QString,25>;
}
// Set up the contents of myClassA.Inputs[]. Then...
ClassB myClasseB;
// Check the arrays are the same length
assert(myClasseA.Inputs.size() == myClasseB.Inputs.size());
for(size_t i=0; i < myClasseA.Inputs.size(); i++)
{
myclasseB.Inputs[i] = myClasseA.Inputs[i];
qDebug() << "this is data",myclasseB.Inputs[i];
}
|
EDIT: Fixed the code to use the same array definition as the OP.
This gives myclasseB a copy of the array from myclasseA. This means that if you change the contents of one of them, the other will not change.
It may be that, instead, you want to give ClassB access to the actual array stored in ClassA, rather than having its own copy of the array. If so, ClassB should have a pointer or reference as the data member, rather than its own array.