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
What is a storage class used in c++?
What is meant by the term name mangling in c++?
What do you mean by inheritance in c++?
What is the latest version on c++?
How to declare a pointer to an array of integers?
Write about the use of the virtual destructor?
Explain virtual destructor?
Write a function to perform the substraction of two numbers. Eg: char N1="123", N2="478", N3=-355(N1-N2).
How we can differentiate between a pre and post increment operators during overloading?
What does obj stand for?
How many types of modularization are there in c++?
What are c++ variables?
an operation between an integer and real always yeilds a) integer result b) real result c) float result
What is the iunknown interface?
What is a far pointer? where we use it?