I created a class called "Message". I want to store Messages that are created with the class "Message" in a static vector array in a class named "MessageBox". The compiler tells me that Message doesn't exist, but the editor is telling me otherwise. Here are the files with the code:
"Message.h"
#pragma once
#include <iostream>
#include <string>
#include "Message Box.h"
namespace ATE {
class Message
{
public:
Message(std::string act, std::string ID, std::string IDtwo) { action = act, ID1 = ID, ID2 = IDtwo; }
Message(std::string act, std::string ID) { action = act, ID1 = ID; }
std::string action;
std::string ID1;
std::string ID2 = nullptr;
};
}
"Message Box.h"
#pragma once
#include <string>
#include <vector>
#include "Message.h"
namespace ATE {
class MessageBox
{
public:
static std::vector<Message> MsgBox;
void addMessage(Message msg);
};
}
"Message Box.cpp"
#include "Message Box.h"
void ATE::MessageBox::addMessage(Message msg)
{
MsgBox.push_back(msg);
}
My errors:
Error C2065 'Message': undeclared identifier (file: message box.h, line: 11)
Error C2923 'std::vector': 'Message' is not a valid template type argument for parameter '_Ty' (file: message box.h, line: 11)
Error C2061 syntax error: identifier 'Message' (file: message box.h, line: 12)
Help is much appreciated (:
windows.h
has the nasty habit of #definingMessageBox
. You might suddenly see an error onATE::MessageBoxW
, macro's do not respect scope. – MSalters