I am trying to make a Client-Server program that would let me write to someone. Everything worked right when I made it server-side. Now that I want to implement the same function I made for the server-side in the Client's, Visual Studio says I can't because he doesn't recognize 'string'. I tried with and without the includes of string, but it won't work either way.
Here's what the code look like for the Client :
#pragma once
//#include <winSock2.h>
//#include <Windows.h>
#include "ClientNetwork.h"
#include "NetworkData.h"
#include <string>
#include <string.h>
class ClientGame
{
public:
ClientGame();
~ClientGame(void);
ClientNetwork* network;
void sendActionPackets();
char network_data[MAX_PACKET_SIZE];
void update();
void sendMessagePacket(string message);
};
Visual Studio gives me "syntax error : identifier 'string'. Yet, I clearly included it in all the ways possible up there.
Also, I have the same code in the same project but for the Server-side of my program. Here it is :
#pragma once
#include "ServerNetwork.h"
#include "NetworkData.h"
class ServerGame
{
public:
ServerGame(void);
~ServerGame(void);
void update();
void receiveFromClients();
void sendActionPackets();
void sendMessagePacket(string message);
private:
//IDs for the clients connection for table in ServerNetwork
static unsigned int client_id;
//The ServerNetwork object
ServerNetwork* network;
//data buffer
char network_data[MAX_PACKET_SIZE];
};
And it works even without the #include string / string.h. Does someone know why it does that?
**EDIT I should've specified, I did try to scope it into std this way "std::string", too. But yet, it won't work.
**Looks like it's "Solved" Removing the "string.h" include but keeping the simple "string" and adding the "std::" scope solved it. I'm still pretty confused as to why there is no problem in my server-sided version. I didn't have to include nor to scope it.. Anyway, I should be alright! Thnanks! :)