LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   C++: Trouble declaring dynamic array (https://www.linuxquestions.org/questions/programming-9/c-trouble-declaring-dynamic-array-378558/)

Hady 10-31-2005 04:47 AM

C++: Trouble declaring dynamic array
 
Hi,

Simple question I guess:

Code:

double *array = new double[variableSize];  // WORKS FINE!
now I want to do:

Code:

double *array[3] = new double[variableSize][3];
I get the error:
cannot convert from 'double (*)[3]' to 'double *[3]'

How do I solve this error?

Many thanks in advance for your much appreciated help.

nx5000 10-31-2005 05:28 AM

Re: C++: Trouble declaring dynamic array
 
Quote:

Originally posted by Hady


Code:

double (*array)[3] = new double[variableSize][3];


Hady 10-31-2005 05:33 AM

Merci beaucoup!!

dmail 10-31-2005 05:53 AM

Re: Re: C++: Trouble declaring dynamic array
 
Code:

double (*array)[3] = new double[variableSize][3];
hmm i didnt know you could do that, i use
Code:

int variableSize, msize;

double **array = new double*[variableSize];
for(int i=0;i<=variableSize-1;i++)array[i] = new double[msize];

thanks for that

nx5000 10-31-2005 06:04 AM

In fact I used the same as dmail :)
The first is not correctly initialized..

nx5000 10-31-2005 06:10 AM

Quote:

Originally posted by Hady
Merci beaucoup!!


Un tres bon cours en francais:

ftp://ftp2.developpez.be/developps/c/PolyCpp.pdf

nx5000 10-31-2005 06:15 AM

It is correct , I was not sure , I tried
:D

Hady 11-01-2005 01:06 AM

merci nx5000 pour le cours C++ en français!

et à bientôt!


All times are GMT -5. The time now is 03:24 PM.