Click here to Skip to main content
15,662,823 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to have a vector of a struct. That's easy but when I try to define a iterator for it I get this error on line 23 (the last line where I try to declare the interator)

template<class _Tp, class _Alloc> class std::vector’ used without template parameters. Here is all the code

C++
#include <vector>

 struct Field{
    int idFieldsid;
    char* FieldId;
    char* Name;
    int Type;
    int Length;
    int FieldPrecision;
    char* isPrimaryKey;
    char* isRequired;
    char*fieldVisible;
    char* EmumValues;

    } ;
using namespace std;
int main()
{


vector<Field> FieldsResults;
vector::<Field>::std::iterator FieldsResultsit;

}


What I have tried:

I tried googling this but all the answers gave a complex explanation but no good example. I'm hoping to get some sample code to fix this
Posted
Updated 10-Jan-17 9:34am
v2
Comments
jeron1 10-Jan-17 14:28pm    
That can't be all the code, edit the original post and retry putting all the code there.

Something like

std::vector<field>::iterator my_iterator;

doesn't work?
JohnnyG62 10-Jan-17 14:44pm    
I pasted the rest of the code.
jeron1 10-Jan-17 15:11pm    
Try making it look more like what I had, something like;

std::vector<field>::iterator my_iterator;
JohnnyG62 10-Jan-17 16:07pm    
This still didn't work but Richard's suggestion works

1 solution

Your declaration of the iterator is wrong, it should be:
C++
	vector<Field>::iterator FieldsResultsit;


// not  
//     vector::<Field>::std::iterator FieldsResultsit; 
 
Share this answer
 
Comments
JohnnyG62 10-Jan-17 16:06pm    
yes that works !

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900