Salut,

J'ai un problème avec ce code:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <vector>
#include <iostream>
#include <cstring>
 
using namespace std;
 
template <class T, unsigned num>
class fixed_array
{
    public:
        T *data;
 
        fixed_array()
        {
            data = new T[num];
        }
        ~fixed_array()
        {
            delete [] data;
        }
        T &operator [] (unsigned i)
        {
            return data[i];
        }
        const T &operator [] (unsigned i) const
        {
            return data[i];
        }
        unsigned size() const
        {
            return num;
        }
};
 
int main()
{
    fixed_array<char, 18> tab;
    strcpy (tab.data, "Hello World.");
    tab[11] = '!';
 
    cout << tab.data << endl;
 
    /* Le code suivant pose problème */
    /*
    vector <fixed_array<char, 18>> tab2;
    /**/
    return 0;
}
C'est quand on décommente la ligne:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
    vector <fixed_array<char, 18>> tab2;
Je n'ai vraiment aucune idée de comment résoudre ça!

voila les erreurs:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
-------------- Build: Release in dvp ---------------

Compiling: main.cpp
C:\Users\Dave\Documents\CODING\projets\dvp\main.cpp: In function `int main()':
C:\Users\Dave\Documents\CODING\projets\dvp\main.cpp:45: error: `tab2' was not declared in this scope
C:\Users\Dave\Documents\CODING\projets\dvp\main.cpp:48: error: template argument 2 is invalid
C:\Users\Dave\Documents\CODING\projets\dvp\main.cpp:48: error: template argument 1 is invalid
C:\Users\Dave\Documents\CODING\projets\dvp\main.cpp:48: error: template argument 2 is invalid
C:\Users\Dave\Documents\CODING\projets\dvp\main.cpp:48: error: expected unqualified-id before '}' token
La classe fixed_array est censée être comme un vector, mais de taille fixe.