Advertisement
Advertisement
| 06.29.2008 at 01:10PM PDT, ID: 23525313 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: |
/*=========== class/variable definitions in .LIB: =============*/
namespace Physics {
struct Dimensions {
float Current, Length, LuminousIntensity,
Mass, Quantity, Temperature, Time;
};
class DimQty { // abstract class
public:
enum Type {
Null, // dimensionless quantity
/* SI base types */
Current, ...
/* SI derived types */
...
/* ------------------------ */
Unknown // wildcard for any combo not listed above
};
/// this is the array that is mentioned in title
static const Dimensions DefinedTypes[Unknown];
static void initialize();
// ctor, dtor & other funcs go here
protected:
static bool inited;
Dimensions * dims;
};
}
// ------------- src ------------
const Dimensions DimQty::DefinedTypes[DimQty::Unknown] = {{0}};
bool DimQty::inited = false;
void DimQty::initialize()
{
Dimensions * def = const_cast<Dimensions*>(DefinedTypes);
def[Current].Current = 1;<< access violation here
def[Length].Length = 1;<< and here
def[LuminousIntensity].LuminousIntensity = 1;<< and here
def[Mass].Mass = 1;<< etc
def[Quantity].Quantity = 1;<<
def[Temperature].Temperature = 1;<<
def[Time].Time = 1;<<
...
}
DimQty::DimQty(const Dimensions *_dims)
{
if (!inited)
initialize();
...
}
|