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
Write a corrected statement in c++ so that the statement will work properly. if (4 < x < 11) y=2*x;
Mention the ways in which parameterized can be invoked.
What is a c++ object?
What is recursion?
How can you create a virtual copy constructor?
Which software is used to run c++ program?
How can we read/write Structures from/to data files?
What do you mean by inheritance in c++?
Why do we need c++?
Can static member variables be private?
Is main a class in c++?
Which operator cannot overload?
Is java easier than c++?
What is c++ good for?
What is a buffer c++?