How can you quickly find the number of elements stored in a
a) static array b) dynamic array ?
Answer Posted / jaroosh
a) sizeof(array)/sizeof(element)
b) you cant (well, you can, eg. by using realloc, counting
from 0 up, and checking the result etc. but this is absurd),
its best to keep track somehow how many elements are there
in the array, but the BEST solution is...do NOT use dynamic
arrays at all, use std containers instead like vector.
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
Mention the ways in which parameterized can be invoked. Give an example of each.
What is the difference between #import and #include in c++?
What is an iterator class in c++?
What is the use of "new" operator?
What is pointer in c++ with example?
Why do we use structure in c++?
Comment on local and global scope of a variable.
Define upcasting.
Would you rather wait for quicksort, linear search, or bubble sort on a 200000 element array? (Or go to lunch...) a) Quicksort b) Linear Search c) Bubble Sort
Differentiate between C and C++.
Who discovered c++?
Write a recursive program to calculate factorial in c++.
What is fflush c++?
Array base access faster or pointer base access is faster?
What are the advantages of using const reference arguments in a function?