So I've been getting this error in Visual Studios 2013 and I can't seem to figure out why.
Network.h:
#ifndef NETWORK_H
#define NETWORK_H
#include <iostream>
#include <vector>
#include "User.h"
#include "stdafx.h"
using namespace std;
class Network{
vector<User*> users;
public:
void sendMessage(istream&);
};
#endif
Network.cpp:
#include "stdafx.h"
#include <iostream>
#include <string>
#include <vector>
#include "Network.h"
using namespace std;
void Network::sendMessage(istream& ss){
string msg, user;
ss >> user;
for (size_t i = 0; i < users.size(); i++){
if (users[i]->getName() == user){
users[i]->addMessage("this is a message");
}
}
}
User.h:
#ifndef USER_H
#define USER_H
#include <iostream>
#include <string>
#include <vector>
#include "stdafx.h"
using namespace std;
class User{
vector<string> messages;
public:
void addMessage(string), readMessages();
};
#endif
Error:
error LNK2019: unresolved external symbol "public: void __thiscall User::addMessage(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?addMessage@User@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: void __thiscall Network::sendMessage(class std::basic_istream<char,struct std::char_traits<char> > &)" (?sendMessage@Network@@QAEXAAV?$basic_istream@DU?$char_traits@D@std@@@std@@@Z) C:\Users\Ethan\Documents\Visual Studio 2013\Projects\SN Project\SN Project\Network.obj SN Project
The error happens at the line "users[i]->addMessage("this is a message")". I've look around and I haven't found any solution to my problem (or whats even causing it). Thanks!