W
William
In Peer.h, I have:
class Peer {
// ...
};
In Overseer.h, I have:
#include "Peer.h"
#include <vector>
using namespace std;
class Overseer {
private:
vector<Peer> connectedPeers;
public:
vector<Peer> getConnectedPeers() {
return connectedPeers;
}
};
I got the following error when I attempted to compile my code:
In file included from Communications.h:19,
from Peer.h:4,
from Peer.cc:1:
Overseer.h:11: error: `Peer' was not declared in this scope
Overseer.h:11: error: template argument 1 is invalid
Overseer.h:11: error: template argument 2 is invalid
Overseer.h:11: error: ISO C++ forbids declaration of `connectedPeers' with
no
type
Overseer.h:14: error: `Peer' was not declared in this scope
Overseer.h:14: error: template argument 1 is invalid
Overseer.h:14: error: template argument 2 is invalid
Overseer.h:14: error: ISO C++ forbids declaration of `getConnectedPeers'
with
no type
make: *** [Peer.o] Error 1
In Overseer.h, it is very clear that I have #include "Peer.h".
1) What is the cause of the error?
2) Any suggestions for a fix is appreciated.
Thanks.
class Peer {
// ...
};
In Overseer.h, I have:
#include "Peer.h"
#include <vector>
using namespace std;
class Overseer {
private:
vector<Peer> connectedPeers;
public:
vector<Peer> getConnectedPeers() {
return connectedPeers;
}
};
I got the following error when I attempted to compile my code:
In file included from Communications.h:19,
from Peer.h:4,
from Peer.cc:1:
Overseer.h:11: error: `Peer' was not declared in this scope
Overseer.h:11: error: template argument 1 is invalid
Overseer.h:11: error: template argument 2 is invalid
Overseer.h:11: error: ISO C++ forbids declaration of `connectedPeers' with
no
type
Overseer.h:14: error: `Peer' was not declared in this scope
Overseer.h:14: error: template argument 1 is invalid
Overseer.h:14: error: template argument 2 is invalid
Overseer.h:14: error: ISO C++ forbids declaration of `getConnectedPeers'
with
no type
make: *** [Peer.o] Error 1
In Overseer.h, it is very clear that I have #include "Peer.h".
1) What is the cause of the error?
2) Any suggestions for a fix is appreciated.
Thanks.