en passant d'un vecteur en fonction de c++

J'ai un main.cpp test.h et de test.rpc> je suis en train de passer mon vecteur à travers ce que je peux l'utiliser dans test.cpp mais je continue à recevoir des erreurs.

   //file: main.cpp
    int main(){
        vector <Item *> s;
         //loading my file and assign s[i]->name and s[i]-address
         tester(s);
    }

    //file: test.h
    #ifndef TEST_H
    #define TEST_H
    struct Item{
        string name;
        string address;
    };
    #endif

    //file: test.cpp
    int tester(Item *s[]){
        for (i=0; i<s.sizeof();i++){
            cout<< s[i]->name<<"  "<< s[i]->address<<endl;
        }
        return 0;
    }



    ---------------errors--------
    In file included from main.cpp:13:
    test.h:5: error: âstringâ does not name a type
    test.h:6: error: âstringâ does not name a type
    main.cpp: In function âint main()â:
    main.cpp:28: error: cannot convert âstd::vector<Item*, std::allocator<Item*>  to âItem**â for argument â1â to âint tester(Item**)â
  • le std::vector type n'est pas un tableau, c'est juste agit comme un tableau. Vous avez pour changer le Point *s[] pour std::vector<Article>
InformationsquelleAutor TT12 | 2011-10-06