Doubt in Abstract Data Type list

Hi,
I just started learning c++, in my classroom the teacher wrote code of static list using class template, the list is based on an array, it works fine for what was tried, integers, floats, strings and as well for abstract data (classA), because he wrote also a class that has one integer, one float and one string so the class template list is also able to work with that abstract data type, everything was tried in the same console application and worked fine, my questions for abstract data type, how or where this list store those data, I moreless understand how it works with the template for integers, floats and strings but I can not understand how it does for the 3 data types at the same time, I mean in a classA datatype together.
For example if data is integer with the template is like cresting an integer array, for floats it is like creating a float array, same for string, but what about classA datatype, does it create 3 arrays? one for integer, one for float and one for string? or it is a single array containing addresses to each of classA instances?
Please help, I want to understand and I can not ask the teacher because it was supposed he already explained.
Thanks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//-----------you can see here the array that was used l[100] in staticlist hearder file--------------
 template <class T1>
class StaticList
{
private:
    int cont;
    T1 l[100];
template <class T1>
StaticList<T1>::StaticList()
{
    cont = 0;
}
//-----------here you can see how the adt classA was defined in classA header file --------------
class ClassA
{
private:
    int iInteger;
    string sString;
    float fFloat;
public:
    ClassA();
    ClassA(int, float, string);

//------------
ClassA::ClassA(int a, float b, string c)
{
    iInteger= a;
    fFloat= b;
    sString= c;
}
//------------in the main an instance is created-------------
StaticList<ClassA> listClassA;
> does it create 3 arrays? one for integer, one for float and one for string?
> or it is a single array containing addresses to each of classA instances?
neither
T1 l[100]; creates a single array that contains the instances
[{i1, f1, s1}, {i2, f2, s2}, {i3, f3, s3}, ..., {in, fn, sn}]

> I can not ask the teacher because it was supposed he already explained.
of course you can ask.
Last edited on
Thank you ne555, it is clear now with your explanation, yeah I should be able to ask the teacher, but he is very special, not very open to discuss, anyway thanks, it was very helpful.
Topic archived. No new replies allowed.