answersLogoWhite

0

You simply instantiate the array for each type. That's the beauty of template (or generic) programming.

vector<int> myIntArray;

vector<double> myDoubleArray;

vector<myClass> myClassArray;

myDoubleArray.push_back(3.5);

myDoubleArray.push_back(6.7);

myDoubleArray.push_back(3.14159);

The myDoubleArray (actually, it called a vector, which is the container type most closely like an array) now contains 3.5, 6.7, 3.14159, and you can easily use them naively, as in myDoubleArray[1] is equal to 6.7, etc.

Of course, the power of STL containers is that you can use various algorithms on them, and you can create iterators to more easily traverse them, but this is enough to answer the question.

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

What does nial mean?

It is a high-level programming language: Nested Interactive Array Language.


What is the definition of array length in the Java programming language?

When programming in Java language, you will need to use container objects to hold your specific values and these are called Arrays. The amount of values held in these containers is called the Array Length. This is generated once an Array is created and the length becomes locked.


Is two dimensional array is multi dimensional array in c language?

Yes because multi means more than one in programming, just like it does in English. No isn't that a surprise. Have you read any good programming text books lately.


What symbol or character determines end of string?

In C programming language, a string is an array of characters which is always terminated by a NULL character: '\0'


Is it necessary to give the size of array?

Depends on the language. For C, no you don't. You can type blank brackets (int Arr[]) when declaring the array, or you can just use a pointer (int* Arr). Both will allow you to use the variable as an array without having to declare the specific size. Hope this answers your question. In Java, an array is an object, and one which is dynamically allocated space. The default constructor does not require a size be specified.


Which one is used in array programming SISD or MISD?

MISD is used in systolic array.


How do you set the null value in array?

Depends on the programming language, some languages may have already initialize an array with null (or the default value of the type), some of them require explicitly assignments by stepping through each element of that array, and assigning them with null. (imperative languages)


Why is an array called a derived data type?

An array is not a derived data type at all. In order to be derived there has to be a base class and an array has no base class. Here is the basic declaration of the std::array template class from the &lt;array&gt; header file: template&lt;class _Ty, size_t _Size&gt; class array { // fixed size array of values // ... }; A vector, on the other hand, is derived (from the &lt;vector&gt; header file): template&lt;class _Ty, class _Alloc = allocator&lt;_Ty&gt;&gt; class vector : public _Vector_alloc&lt;!is_empty&lt;_Alloc&gt;::value, _Vec_base_types&lt;_Ty, _Alloc&gt;&gt; { // varying size array of values // ... };


When was the first python array written?

Python is a high level computer programming language. It allows programmers to use clearer code with fewer lines that other languages. A Python array is a method to store data. Whilst it is impossible to precisely date when the first python array was written, development work started on the language in December 1989.


What is a bitset?

A bitset is an array of bits in computer programming.


Why is c string defined as an array?

Every programming language treats strings as arrays. A C string is defined as being a null-terminated array of characters. A C string that does not have a null-terminator is just an array of character values, but without a null-terminator the onus is upon the programmer to keep track of the array's length.


What is an ordered list of data structure using c plus plus?

An ordered list of data in any programming language is simply a sorted array or list. In C++ this can either mean a sorted array, vector, list or forward list.