I define the following struct
struct CCPtDist
{
double[] wDist = new double[8];
};
And I want to build a “CCPtDist” variable called tmpPtDist and want to assign a double number to wDist:
CCPtDist tmpPtDist;
tmpPtDist.wDist[0] = 233.7;
But the g++ compiler returns an error: ‘struct CCPtDist’ has no member named ‘wDist’?
There are a number of things wrong in the code. First off, if you declare an array as a member, the memory is allocated inline as part of the struct. You can’t just assign an arbitrary pointer to it. Second off, I don’t think you declared the array correctly anyway. Third, you need to put complex initialization like that in a constructor.
I’m surprised it doesn’t give you a compile error on the
double[] wDist = new double[8];
line.Try changing it to something like this