need help
-
dear all my problem is below, anyone help me to check, thanks a lot. T,sigma,maskSize,halfSize are all declared. for (int k=0;k<5;k++) { halfSize = static_cast(sqrt(-log(T))*2*pow(sigma[k],2)); maskSize = 2*halfSize + 1; int Mask[k][maskSize][maskSize]; int valueX[k][maskSize][maskSize]; int valueY[k][maskSize][maskSize]; } error C2057: expected constant expression error C2466: cannot allocate an array of constant size 0 so anyone help me. thanks
Li Zhiyuan
-
dear all my problem is below, anyone help me to check, thanks a lot. T,sigma,maskSize,halfSize are all declared. for (int k=0;k<5;k++) { halfSize = static_cast(sqrt(-log(T))*2*pow(sigma[k],2)); maskSize = 2*halfSize + 1; int Mask[k][maskSize][maskSize]; int valueX[k][maskSize][maskSize]; int valueY[k][maskSize][maskSize]; } error C2057: expected constant expression error C2466: cannot allocate an array of constant size 0 so anyone help me. thanks
Li Zhiyuan
If you want to allocate an array from which you don't know the size at compile time (you only know it at runtime), then you need to use new. It is quite basic C++ stuff and it is not the first time you ask that question (even if people already answered you). I think it would be great for you to learn C++ from the start. So, buy a good book and take some time to learn it correctly. You might spend some time on it but at the end, you will be much more efficient. Just an advice though...
Cédric Moonen Software developer
Charting control [v1.3 - Updated] -
If you want to allocate an array from which you don't know the size at compile time (you only know it at runtime), then you need to use new. It is quite basic C++ stuff and it is not the first time you ask that question (even if people already answered you). I think it would be great for you to learn C++ from the start. So, buy a good book and take some time to learn it correctly. You might spend some time on it but at the end, you will be much more efficient. Just an advice though...
Cédric Moonen Software developer
Charting control [v1.3 - Updated] -
dear all my problem is below, anyone help me to check, thanks a lot. T,sigma,maskSize,halfSize are all declared. for (int k=0;k<5;k++) { halfSize = static_cast(sqrt(-log(T))*2*pow(sigma[k],2)); maskSize = 2*halfSize + 1; int Mask[k][maskSize][maskSize]; int valueX[k][maskSize][maskSize]; int valueY[k][maskSize][maskSize]; } error C2057: expected constant expression error C2466: cannot allocate an array of constant size 0 so anyone help me. thanks
Li Zhiyuan
Which part of "Read the forum guidelines" do you not understand? Each time you use these idiotic subject lines "Need Help", "Urgent!!!!! Help!!!!!!!!!!!!!!!!!", etc. you are told to use subject lines that actually describe the problem briefly but you simply refuse to do that. Not to mention that this has been going on for almost 2 years. What is your malfunction?
-
Which part of "Read the forum guidelines" do you not understand? Each time you use these idiotic subject lines "Need Help", "Urgent!!!!! Help!!!!!!!!!!!!!!!!!", etc. you are told to use subject lines that actually describe the problem briefly but you simply refuse to do that. Not to mention that this has been going on for almost 2 years. What is your malfunction?
-
Which part of "Read the forum guidelines" do you not understand? Each time you use these idiotic subject lines "Need Help", "Urgent!!!!! Help!!!!!!!!!!!!!!!!!", etc. you are told to use subject lines that actually describe the problem briefly but you simply refuse to do that. Not to mention that this has been going on for almost 2 years. What is your malfunction?
Cranky wrote:
Not to mention that this has been going on for almost 2 years.
:laugh: But, I think he is not a native English speaker. However, 2 years into CP and that won't make an excuse. :)
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
int** myArray; // An uninitialized 2D array, cannot be used this way.
myArray = new int*[10]; // Creates an array of 10 pointers to integer.
// Each of these 10 pointers are not initialized, so again, not usable.for (int i=0;i<10;i++)
{
myArray[i] = new int[20]; // For each of these 10 pointers, we allocate an array of 20 integers.
}So, now you have a 2D array. Don't forget to delete everything once you are done. Here the same applies: you need to delete each row first and then delete the root pointer. I leave you that as an exercice to see if you understand the concept ;) .
Cédric Moonen Software developer
Charting control [v1.3 - Updated] -
what about vector vector combination!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/codeProject$$>