Bonjour,
je débute à peine sur C++, et j'essaie de renvoyer un tableau dynamique via ma fonction que j'ai sortie de mon main
voici sa déclaration :
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
#include "AppTableau.h"
 
#include <vector>
#include <string>
std::vector<int> GestTabStatic(int Val, bool App, int Tab[], int Tail){
    int cpt;
    std::vector<int> tab2();
 
    if (App){
        for (int i=0;i<Tail;++i){
            if(Tab[i] > 10){
                ++cpt;
                tab2.push_back() = Tab[i];
            }
        }
    }else if{
        Tab[Tail]=Val;
 
    }
    return tab2;
}
et voici son prototype dans le .h
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
#ifndef APPTABLEAU_H_INCLUDED
#define APPTABLEAU_H_INCLUDED
 
#include <vector>
std::vector<int> GestTabStatic(int Val, bool App, int Tab[], int Tail);
 
#endif // APPTABLEAU_H_INCLUDED
simplement en compilanat j'ai les messages d'erreurs suivants :
13|error: request for member 'push_back' in 'tab2', which is of non-class type 'std::vector<int>()'|
16|error: expected '(' before '{' token|
20|error: could not convert 'tab2' from 'std::vector<int> (*)()' to 'std::vector<int>'|
merci a tous