Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,299 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,034 people online right now. Registration is fast and FREE... Join Now!




static v/s dynamic variable declaration

 
Reply to this topicStart new topic

static v/s dynamic variable declaration

prads
post 14 Mar, 2008 - 08:17 PM
Post #1


D.I.C Head

**
Joined: 22 Oct, 2007
Posts: 111


My Contributions


Hello,
One quick question. Is it better to assign array size , especially when its large such as a[30000], during compile time or run time inorder to make it run fast? Well as far as i know the latter one is preferable, but i just used the Profiling Tool and found out that the new[] and delete[] operators consume some quality time especially when it runs in a loop of say 30000! So can somebody please help me out?
thanks,
prads
User is offlineProfile CardPM

Go to the top of the page

KYA
post 14 Mar, 2008 - 09:45 PM
Post #2


#include <nerd.h>

Group Icon
Joined: 14 Sep, 2007
Posts: 4,205



Thanked 50 times

Dream Kudos: 1150
My Contributions


It depends on how the array is being used. If the program will never get anywhere near the array maximum, then you should have input to deterime the proper size (i.e. dynamically). Especially if the array won't be filled or close to it, it would be wasting memory...
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/22/08 01:41AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month