Thread: reference, struct & vectors

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    19

    reference, struct & vectors

    I am trying to pass a reference to struct based vector but keep getting an error "C2923:'std::vector' : 'InstalledApps' is invalid as template argument '#1', type expected"

    See my attempt below, What is the best way to accomplish this task?


    Thanks,

    JD..


    Code:
     
    
    #include "stdafx.h"
    #include "windows.h"
    #include <vector>
    #include <string>
    
    using namespace std;
    
    struct InstalledApps {
                                     string Vendor;
                                     string PartNumber;
    	             string Status;
                                     };
    
    
    int main(void)
    
    {
    vector<ProductList> ProdList;
    GetProdlist(ProdList);
    }
    
    
    //external file
    
    using namespace std;
    
    extern InstalledApps;
    void GetProdList(vector<ProductList>& ProdList);
    
    GetProdList(vector<ProductList>& ProdList)
    {
    
    Do something here
    
    };

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    ProductList is never declared or defined anywhere, I guess you mean InstalledApps.
    Code:
    extern InstalledApps;
    This is an incorrect struct declaration, correct would be
    struct InstalledApps;
    but it doesn't matter as the template argument to an STL container must be a full type.

    Put the struct definition into a header file and include it in both sources.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. C OpenGL Compiler Error?
    By Matt3000 in forum C Programming
    Replies: 12
    Last Post: 07-07-2006, 04:42 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Bi-Directional Linked Lists
    By Thantos in forum C Programming
    Replies: 6
    Last Post: 12-11-2003, 10:24 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM