• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.
    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

C++ Vector Implementation

td611

New Coder
I declare a vector of object Persons

C++:
#ifndef PostO_H
#define PostO_H
#include "Person.h"
#include "Address.h"
#include <iostream>
#include <string>
using namespace std;
class PostO
{
private:
vector <Person> mList[];

When I do so, I get this error, underlining mList.

"incomplete type is not allowed"

What does this mean, and how do I resolve it?
 
Last edited by a moderator:

Krusty the Senile

Active Coder
You may need to #include <vector> if it hasn't been included in any of the other header files.
You should also be able to declare vector<Person> mList; without the brackets - your declaration is defining an array of vectors but without a given array size (maybe that's the problem?). So instead of mList[3].push_back(aPerson); I think your intention is mList.push_back(aPerson);.
 
Top