|
That only works for stack based arrays. And arrays on the stack is a bad coding practice (except for really small, fixed size arrays). Stack space is precious while heap space is not (not as precious as stack space anyway)
--
C'est normal!
|
|
|
|
|
Thanks for replying.
It's a good thought, but if you're serious about maximizing reuse of your code, you cannot have duplicate codes doing the same thing at different locations in your program just so you can take advantage of what you're suggesting.
William
Fortes in fide et opere!
|
|
|
|
|
If you're thinking of something like this:
size_t x, y;
int bigarray[x][y]; then no, that is illegal because array sizes must be known at compile time. (gcc allows this, but it's a non-standard extension.)
You can build your own array at runtime with lots of new calls though.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | 1ClickPicGrabber New v2.0.1! | RightClick-Encrypt
"Linux is good. It can do no wrong. It is open source so must be right. It has penguins. I want to eat your brain."
-- Paul Watson, Linux Zombie
|
|
|
|
|
Really?! Bummer. I was so positive that C++ is allowed to create variable length arrays on the stack. I just verified it in VS.NET too.
--
C'est normal!
|
|
|
|
|
If u are dealing with the array like this int arr[x][y] at compile time than by using pointers u can do it at runtime like for one dimensional array int *arr=new int[x];
where x can have any value similarly one can do it for two dimensional array.
Inam
|
|
|
|
|
Thanks for replying.
If you are referring to:
int** ConstructMatrix(const int sz)
{
int** pMtrx = new int *(Matrix)[sz];
return pMtrx;
} Then by passing a value which you are going to assign sz at run time, forget it. It doesn't work.
William
Fortes in fide et opere!
|
|
|
|
|
Im sure, there is no way, because the compiler
needs the arraysize to make the pointer arithmetic right. I spent one or two days on it and found
no solution
then I used a normal array (one dimension)
and made the arithmetics myself.
<br />
for(int n=0;n< m_nFieldCount;n++)<br />
{<br />
for(int m=0;m< m_nFieldCount;m++) <br />
{ <br />
if(m_dRatingMatrix[n*m_nRatingMatrixSize+m]>0) <br />
{ <br />
do some stuf<br />
}<br />
}<br />
}<br />
|
|
|
|
|
|
if you want to allocate a table (whatever its size and its dimension) depending on the datas inside, you don't have other ways to use dynamic allocation. if you are in C, use malloc() , calloc() , realloc() , but be careful, they are non-reantrant functions. if you program in C++, prefer new operator, and even if it sizes you source by adding code lines on the treatment of the memory, you win in the place your datas take in memory...
TOXCCT
|
|
|
|
|
Thanks for replying.
The problem is NOT with the allocation of memory. Operator 'new' makes easy job of that (providing there is enough space on the heap). The problem is getting around the compiler's insistence that the size of the array be known at compile time. That IS the problem!!
The main objective is NOT whether memory is to be statically allocated, or dynamically allocated. The main problem is with the SIZE of the memory I wish to allocate, which the compiler is insisting it MUST know at compile time.
I am trying to find out if there is a way I can let the compiler know that information at run time, which so far it is saying, "NO!!"
William
Fortes in fide et opere!
|
|
|
|
|
could you please show me a line you wrote to which the compiler says "NO"...
i don't really understand why it would answer like that...
thanks
TOXCCT
|
|
|
|
|
It's a figure of speech I was using.
William
Fortes in fide et opere!
|
|
|
|
|
hi
i read in an article that there is a utility here on codeproject to convert vs.net projects to vs6 project, but i cant find it.
could somebody point me to it ?
thanx
|
|
|
|
|
|
thank you very much
thats seems exactly like it
|
|
|
|
|
Howdy friends!
I'm working on project about VLDB. I developed an application server and its SDK. Data size approximately 15.000.000 records which is remain on Microsoft Analysis Services (OLAP). System configuration at below;
2 Hyper Threading Intel Xeon CPU,
2 gb Memory
RAID 1, RAID 5
Windows 2000 Advanced server
Compaq Proliant Server
But, it didn't give expected response time for us (20 secs for 5.000.000 records) . The question is, can i access all of the data in 15 sec. What is the wrong? Anybody can recommend any site or book about vldb?
Thank you
Ahmet Orkun GEDiK
System & Software Support Specialist (SAP R/3)
ASTRON
|
|
|
|
|
hi freinds,
Can any one help to convert an programmitically generated image transparent
|
|
|
|
|
How transparent?
Are you talking about alpha chanel or transparency mask
and how to create that mask?
Delf
|
|
|
|
|
Hi,
I am trying to use the CArray class as follow:
class CVueAtelier
{
protected :
CArray<cvuecomposant, cvuecomposant=""> vueElementsAtelier;
...
}
where CVueComposant is an abstract class I defined
and when I try to build this is the error I get :
...\include\afxtempl.h(201) : error C2259: 'CVueComposant' : cannot instantiate abstract class due to following members:
...\cvuecomposant.h(15) : see declaration of 'CVueComposant'
...\cvueatelier.h(26) : see reference to class template instantiation 'CArray<class cvuecomposant,class="" cvuecomposant="">' being compiled
Please help me,
Pierre
|
|
|
|
|
CArray is a template.
Example: CArray<cpoint,cpoint> ptArray;
INTP
|
|
|
|
|
CArray<point,point> ptArray;
INTP
|
|
|
|
|
We made a hardware for digitizing video data . I want to program a driver for this card . But I dont have soutable document to study driver programming . Please define me soutable document ?
Very Thanks ------>> ;
|
|
|
|
|
|
Hello: There are several books available for writing drivers. Assuming that your developing for NT/Win2k/XP the book I recommend is by Walter Oney called "Programming the Microsoft Windows Driver Model, Second Edition ". You will also need to order the DDK from Microsoft.
Dave Jones
|
|
|
|
|