我正在尝试使用MVC模式在C ++上完成我的第一个应用程序。所以,我有一个视图类ClientTsFrm和ClientTS类,即控制器。为了通知视图类,我决定使用Observer模式,因此来自Subject.h的ClienTS遗产。
ClientTsFrm有一个名为ClientTS的成员来进行通信,但是当我构建项目时,它显示了这个错误:
错误10错误C4430:缺少类型说明符 - 假定为int。注意:C ++不支持default-int(src \ lib \ ClientTS.cpp)
错误9错误C2146:语法错误:缺少&#39 ;;'在标识符'客户端'之前(src \ lib \ ClientTS.cpp)
ClientTsFrm.h
#pragma once
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <wx/wx.h>
#include <wx/frame.h>
#else
#include <wx/wxprec.h>
#endif
#include "../Data/config.h"
#include "../lib/ClientTS.h"
#include "../data/Session.h"
#include "../data/Message.h"
#include <wx/sizer.h>
#include <wx/wx.h>
#include <wx/timer.h>
#include <wx/stattext.h>
#include <wx/richtext/richtextctrl.h>
#include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/grid.h>
#include "NationList.h"
#include "LoginWarnings.h"
#include "../ArchiveLog.h"
#include "../GlobalVariables.h"
#include "../translateController/translateController.h"
#include "../translateController/translateVariable.h"
#include "FrmMailSending.h"
#include "FrmSettingMail.h"
#include "AudioWizard.h"
#include <list>
#include "FrmSaveChat.h"
//#include "../data/observer.h"
#define MENU_ESCI 1800
#define MENU_OPZIONI 1801
#define MENU_SPEECH 1802
class ClientTsFrm : public wxFrame
{
private:
DECLARE_EVENT_TABLE();
double conta;
void askForSaving();
void WxButton1Click(wxCommandEvent& event);
void btnsendClick(wxCommandEvent& event);
void txtchatClick(wxRichTextEvent& event);
void txtchatEnter(wxCommandEvent& event);
void OnTimerTimeout(wxTimerEvent& event);
void WxTimer1Timer(wxTimerEvent& event);
void txtmsgEnter(wxCommandEvent& event);
void RefreshChat();
void btnspeechClick(wxCommandEvent& event);
void ClientTsFrmActivate(wxActivateEvent& event);
void WxButton2Click(wxCommandEvent& event);
void WxTimer2Timer(wxTimerEvent& event);
void gridchatCellLeftClick(wxGridEvent& event);
void Debug(wxCommandEvent& event);
void Wizard(wxCommandEvent& event);
void WxBitmapButton1Click(wxCommandEvent& event);
void Mail(wxCommandEvent& event);
void SettingMail(wxCommandEvent& event);
void Save(wxCommandEvent& event);
void OnClose(wxCloseEvent& event);
void notifyMsg(MessagePTR msg);
public:
ClientTsFrm(LoginWarnings *warn, wxWindow *parent, wxWindowID id = 1, const wxString &title = wxT("TeamTranslate"),
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX | wxRESIZE_BORDER);
virtual ~ClientTsFrm();
//void ClientTsFrm::notify(ClientTsFrm fn);
private:
Session* session;
ConfigPTR config;
NationList *nations;
int REFRESHTIMER = 0;
uint64 _sclogID;
wxTimer *WxTimer2;
wxTimer *WxTimer1;
wxButton *btnspeech;
wxRichTextCtrl *txtclient;
wxTextCtrl *txtlingua;
wxStaticText *lbllingua;
wxStaticText *lblnick;
wxTextCtrl *txtnick;
wxRichTextCtrl *txtchat;
wxButton *btnsend;
wxTextCtrl *txtmsg;
wxGrid *gridchat;
wxGrid *gridclient;
wxBoxSizer *sizer;
wxGridSizer *gridsizer;
wxMenuBar *WxMenuBar1;
wxMenu *ID_MNU_FILE_1001_Mnu_Obj;
wxMenu *ID_MNU_OPZIONI_1004_Mnu_Obj;
wxBitmapButton *WxBitmapButton1;
ClientTS clientts;
};
ClientTS.h
#pragma once
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <wx/wx.h>
#include <wx/frame.h>
#else
#include <wx/wxprec.h>
#endif
#include "../gui/ClientTsFrm.h"
#include "../data/Session.h"
#include "../data/Message.h"
#include "../data/Config.h"
#include <wx/sizer.h>
#include <wx/wx.h>
#include <wx/timer.h>
#include <wx/stattext.h>
#include <wx/richtext/richtextctrl.h>
#include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/grid.h>
#include "../gui\NationList.h"
#include "../gui\NationInfo.h"
#include "../ArchiveLog.h"
#include "../GlobalVariables.h"
#include "../translateController/translateController.h"
#include "../translateController/translateVariable.h"
#include <list>
#include <functional>
#include "Subject.h"
#include "EventType.h"
#define MENU_ESCI 1800
#define MENU_OPZIONI 1801
#define MENU_SPEECH 1802
class ClientTS : public Subject<EventTS>{
static Session* session;
static ConfigPTR config;
static bool flagSave;
static char LANG_MSG_SRC[500];
static char MSG_SRC[500];
public:
ClientTS(){
session = Session::Instance();
config = session->getConfig();
}
~ClientTS(){}
static char* getLANG_MSG_SRC(){ return LANG_MSG_SRC; }
static char* getMSG_SRC(){ return MSG_SRC; }
static bool getFlagSave(){ return flagSave; }
static void setFlagSave(bool flg){ flagSave = flg; }
static void speak(char *LANG, char*MSG);
static void Print(char*word);
static size_t read_callback(static void *ptr, size_t size, size_t nmemb, static void *userp);
static void writeWaveFile(const char* filename, SAudioStreamFormat format, static void* data);
static void SetupColor();
static void onConnectStatusChangeEvent(uint64 serverConnectionHandlerID, int newStatus, unsigned int errorNumber);
static void onNewChannelEvent(uint64 serverConnectionHandlerID, uint64 channelID, uint64 channelParentID);
static void onNewChannelCreatedEvent(uint64 serverConnectionHandlerID, uint64 channelID, uint64 channelParentID, anyID invokerID, const char* invokerName, const char* invokerUniqueIdentifier);
static void onDelChannelEvent(uint64 serverConnectionHandlerID, uint64 channelID, anyID invokerID, const char* invokerName, const char* invokerUniqueIdentifier);
static void onClientMoveEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, const char* moveMessage);
static void onClientMoveSubscriptionEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility);
static void onClientMoveTimeoutEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, const char* timeoutMessage);
static void onTalkStatusChangeEvent(uint64 serverConnectionHandlerID, int status, int isReceivedWhisper, anyID clientID);
static void onIgnoredWhisperEvent(uint64 serverConnectionHandlerID, anyID clientID);
static void onServerErrorEvent(uint64 serverConnectionHandlerID, const char* errorMessage, unsigned int error, const char* returnCode, const char* extraMessage);
static void onUserLoggingMessageEvent(const char* logMessage, int logLevel, const char* logChannel, uint64 logID, const char* logTime, const char* completeLogString);
static void onCustomPacketEncryptEvent(char** dataToSend, unsigned int* sizeOfData);
static void onCustomPacketDecryptEvent(char** dataReceived, unsigned int* dataReceivedSize);
static void onEditMixedPlaybackVoiceDataEvent(uint64 serverConnectionHandlerID, short* samples, int sampleCount, int channels, const unsigned int* channelSpeakerArray, unsigned int* channelFillMask);
static void showChannels(uint64 serverConnectionHandlerID);
static void showChannelClients(uint64 serverConnectionHandlerID, uint64 channelID);
static void onTextMessageEvent(uint64 serverConnectionHandlerID, anyID targetMode, anyID toID, anyID fromID, const char* fromName, const char* fromUniqueIdentifier, const char* message);
static void showClients(uint64 serverConnectionHandlerID);
static void createChannel(uint64 serverConnectionHandlerID, const char *name);
static void deleteChannel(uint64 serverConnectionHandlerID);
static void renameChannel(uint64 serverConnectionHandlerID);
static void switchChannel(uint64 serverConnectionHandlerID);
static void toggleVAD(uint64 serverConnectionHandlerID);
static void setVadLevel(uint64 serverConnectionHandlerID);
static void requestWhisperList(uint64 serverConnectionHandlerID);
static void requestClearWhisperList(uint64 serverConnectionHandlerID);
static void toggleRecordSound(uint64 serverConnectionHandlerID);
static int readIdentity(char* identity);
static int writeIdentity(const char* identity);
static uint64 enterChannelID();
static void createDefaultChannelName(char *name);
static void enterName(char *name);
};
希望有人可以帮助我。如果您需要更多代码,请告诉我。
感谢您的时间。
编辑。错误发生在这一行(ClientTsFrm.h):
ClientTS clientts;
答案 0 :(得分:2)
两个标题各自试图包含另一个,这是不可能的。一个将首先包含在内,并且无法访问另一个中的声明。
据我所知,ClientTS.h
不需要ClientTsFrm.h
中的任何内容,因此请删除该内容。