error field ... has incomplete type ...

Hi. Can anyone please show me how to solve this problem?
I am writing a BaseFolder class. When I compile my program, Dev C++ keeps giving me these messages:
* In file included from BaseFolder.cpp
* [Error] field '_msg' has incomplete type 'Vec<const Message*>'
* recipe for target 'BaseFolder.o' failed
Here is my BaseFolder.h:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef BASEFOLDER_H
#define BASEFOLDER_H

#include <iostream>
#include <sstream>
#include <ctime>
#include <chrono>
#include <map>
#include <string>

using namespace std;

template<typename T>
class Vec;
class Name;
class Message;
class EmailAccount;


class BaseFolder{
    public:
        
        BaseFolder(EmailAccount *ac);
        virtual ~BaseFolder(){                          
            for (int i=0; i<_msg.size(); ++i){
                delete _msg[i];
            }
           
            cout << "BaseFolder destructor" << endl;
        }
        int size() const ;
        void display() const;
        void erase(int n);
        void forward(int n) const;
        void print(int n) const;
        void receive(const Message *m);
        void reply(int n) const;
    protected:
        virtual string type() const {}
        virtual const Name& tofrom(const Message *m) const = 0;
        
        Vec<const Message*> _msg;
        EmailAccount *_ac;
    private:
        BaseFolder(const BaseFolder &orig);
        BaseFolder& operator= (const BaseFolder &rhs);
};

#endif 


Here is my BaseFolder.cpp:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "BaseFolder.h"
#include "Vec.h"
#include "Name.h"
#include "Message.h"
#include "EmailAccount.h"
#include <iostream>
#include <sstream>
#include <ctime>
#include <chrono>
#include <map>
#include <string>

using namespace std;
BaseFolder::BaseFolder(EmailAccount *ac) : _ac(ac) {
    _msg.push_back(NULL);
}
int BaseFolder::size() const {
    return _msg.size();
}
        
void BaseFolder::display() const{
    cout << _ac->owner().name() << " " << type() << endl;
    if (_msg.size() <= 1) {
        cout << "no message to display" << endl;
    }
    else 
        for (int i=1; i<_msg.size(); ++i){
            const Name &tmp = tofrom(_msg[i]);
            cout << i << ", " << tmp.name() << ", " << _msg[i]->subject() << endl;
    	}
                
    }
void BaseFolder::erase(int n){
    if (n>=1 && n<_msg.size()){
        delete _msg[n];
        _msg.erase(n);
    }
    else return;
}
void BaseFolder::forward(int n) const{
    if (n>=1 && n< _msg.size()){
        const Message *m = _msg[n];
        string fwd_subject = "Fwd: " + m->subject();
        Message *ptr = new Message(_ac->owner().name(), "", fwd_subject, m->text());
        _ac->insert(ptr);
    }
    else return;
}
void BaseFolder::print(int n) const{              
    if (n>=1 && n<_msg.size()){
        _msg[n]->print();   
    }
    else return;
}
void BaseFolder::receive(const Message *m){
    _msg.push_back(m);
}
void BaseFolder::reply(int n) const{
    if (n>=1 && n<_msg.size()){
    	const Message *m = _msg[n];
        string subject = "Re: " + m->subject();
        const Name& tmp = tofrom(m);
        Message *ptr = new Message(_ac->owner().name(), tmp.name(), subject, m->text());
        _ac->insert(ptr);
    }
    else return;
}
        
    
BaseFolder::BaseFolder(const BaseFolder &orig){}
BaseFolder& BaseFolder::operator= (const BaseFolder &rhs){
    return *this;
}
               
Last edited on
If you were only creating a pointer to a Vec then you could just say "class Vec" in BaseFolder.h like you did. But you are creating an actual Vec, so you need to #include "Vec.h".
Topic archived. No new replies allowed.