J
Jon Slaughter
I have a chain of classes(i.e., a series of classes each containing an array
of the next class). Each class has array like access.
struct Myclass1
{
vector(Myclass2) _Myclass2;
Myclass2& operator[](int i);
}
Anyways, I want to be able to do something like
Myclass1 A;
Myclass2 B;
A[3] = B;
that is "caught" by Myclass1. i.e., instead of treating A[3] as a Myclass2
class it would treat it as a Myclass1 class.
Is this possible to do? I know I could write a function in Myclass1 that
would be something like
void assignment(Myclass2& B, int i);
that would do the exact same thing but it would be nice if it were possible
to do the above since it is much easier... in Myclass2 there will be no
assignment operator from Myclass2 to Myclass2 so I don't see why there would
be any confusion... actually, the assignment operator in Myclass2 will do
the exact same but on Myclass3(an so on until the last class, which I don't
know what it will do).
Anyways, using the resolution operator isn't really worth it since it does
exactly the same as the assignment function(though I guess I'd have to
modify it a little to be the exact same).
Jon
of the next class). Each class has array like access.
struct Myclass1
{
vector(Myclass2) _Myclass2;
Myclass2& operator[](int i);
}
Anyways, I want to be able to do something like
Myclass1 A;
Myclass2 B;
A[3] = B;
that is "caught" by Myclass1. i.e., instead of treating A[3] as a Myclass2
class it would treat it as a Myclass1 class.
Is this possible to do? I know I could write a function in Myclass1 that
would be something like
void assignment(Myclass2& B, int i);
that would do the exact same thing but it would be nice if it were possible
to do the above since it is much easier... in Myclass2 there will be no
assignment operator from Myclass2 to Myclass2 so I don't see why there would
be any confusion... actually, the assignment operator in Myclass2 will do
the exact same but on Myclass3(an so on until the last class, which I don't
know what it will do).
Anyways, using the resolution operator isn't really worth it since it does
exactly the same as the assignment function(though I guess I'd have to
modify it a little to be the exact same).
Jon