user defined datatypes

Hello,

I would like to create an user defined datatype based on another user defined datatype.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// curve scenario
typedef struct
{
   int id;
   double tenor[_NO_TENORS];
   double zeroRate[_NO_TENORS];
   double df[_NO_TENORS];
} curveScenario;

// curve data
typedef struct
{
    string name;
    string currency;
    string country;
    string interpolate;
    int interpolation;
    int scenariosNo;
    int tenorsNo;
    curveScenario scenario[_NO_SCENARIOS];
} curveData;


The problem is that

 
curveData curve;


ends with an error when I run the code (compilation is OK though). This is probably because of the line

 
curveScenario scenario[_NO_SCENARIOS];


When I comment the line, the code works fine. So my question is what's the correct way to create an user defined datatype based on another user defined datatype.

Thx a lot in advance,

Michal

PS: I would like to avoid "going around" this problem through creating a special object.
That code is fine. In general, runtime errors are not caused by declarations. There should be something wrong with the rest of your code.
You'll have to post more code. Although, before you do that, try eliminating as many irrelevant parts as you can.
If you would incorrectly use defined types you get a compile error. So your problem has nothing common with defining new types. It is a runtime error.
Hello, you are right - it seems that I exceeded memory that could be allocated to the datatype (I had _NO_SCENARIOS = 10000 and _NO_TENORS = 50). I am using 32b Windows Vista. Could upgrade to 64b OS help? Best regards, Michal
If you need that much memory, allocate your structure on the heap (malloc in C or new in C++).
Stack is, I think, usually set to be 1 MB, while heap can be resized.
Topic archived. No new replies allowed.