| | |
Using New
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
Just been looking over Dynamic Memory Allocation, using new.
Heres a snippet of the code i've got.
what i was thinking was could i just do
instead of the for loop, are there any benefits for using either or are they exactly the same.
thanks in advance
finally one other minor question, currently all of my classes are in the same .cpp file as my main function, is there a way to put the classes into seperate .cpp files rather like java. i tried this initially but got errors about my code, and after moving them into the same file the program ran perfectly.
- Matt
Heres a snippet of the code i've got.
c++ Syntax (Toggle Plain Text)
vertices = new float *[v]; for (i = 0; i < v; ++i) { vertices[i] = new float[3]; }
what i was thinking was could i just do
c++ Syntax (Toggle Plain Text)
vertices = new float[v][3];
instead of the for loop, are there any benefits for using either or are they exactly the same.
thanks in advance

finally one other minor question, currently all of my classes are in the same .cpp file as my main function, is there a way to put the classes into seperate .cpp files rather like java. i tried this initially but got errors about my code, and after moving them into the same file the program ran perfectly.
- Matt
Last edited by midimatt; May 15th, 2008 at 2:00 am.
•
•
Join Date: Nov 2006
Posts: 224
Reputation:
Solved Threads: 31
•
•
•
•
what i was thinking was could i just do
c++ Syntax (Toggle Plain Text)
vertices = new float[v][3];
![]() |
Other Threads in the C++ Forum
- Previous Thread: Threads!
- Next Thread: stack of stack....
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion convert count data delete deploy dll download dynamic dynamiccharacterarray encryption error file format forms fstream function functions game givemetehcodez graph gui homeworkhelp iamthwee ifstream input int java lib library linker list loop looping loops map math matrix memory microsoft newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings struct temperature template templates test text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






