You are here:

C++/programming

Advertisement


Question
Is it possible to store elements with different data types in an aeeay?

Answer
> Is it possible to store elements with different data types in a C++ array?

Short answer: No.

Longer answer: Depends on what you mean by 'different data type'

In a C++ array the static (or compile-time) type of every element in an array would be the same.

However, if the element is a (discriminated) union or a pointer to a polymorphic type, the dynamic (or run-time) type could be different for different elements.

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


vijayan

Expertise

my primary areas of interest are generic and template metaprogramming, STL, algorithms, design patterns and c++11. i would not answer questions about gui and web programming.

Experience

about 15 years or so

Education/Credentials
post graduate engineer

©2016 About.com. All rights reserved.