S
Simon
Hi,
If I have the following :
struct sA
{
double A1;
double A2;
};
struct sB
{
double B1;
long B2;
};
struct sC : sA, sB
{
double C1;
double C2;
};
//
// main app
sC myC = ... // set some values;
sA myA = (sA)myC;
sB myB = (sB)myB;
//
//
When I do it on my compiler, VS2009 it works.
In other word the value of myA has the values from myC simply by casting.
And the same for myB getting the right values from myC by casting.
But I doubt there are any rules in the standard that say that when you cast
like that you must copy the right values.
If this is not 'standard' what would be the better way of getting sA and sB
from sC
Many thanks
Simon
If I have the following :
struct sA
{
double A1;
double A2;
};
struct sB
{
double B1;
long B2;
};
struct sC : sA, sB
{
double C1;
double C2;
};
//
// main app
sC myC = ... // set some values;
sA myA = (sA)myC;
sB myB = (sB)myB;
//
//
When I do it on my compiler, VS2009 it works.
In other word the value of myA has the values from myC simply by casting.
And the same for myB getting the right values from myC by casting.
But I doubt there are any rules in the standard that say that when you cast
like that you must copy the right values.
If this is not 'standard' what would be the better way of getting sA and sB
from sC
Many thanks
Simon