Ich "empfange" TCPSocket.h: 35: Fehler: erwartet "," oder "..." vor numerischer Konstante "beim Kompilieren, was ich ziemlich sicher war, vorher Code zu kompilieren.
Zeile 35 ist TCPSocket(int port, bool vOutput, const int DIRECTORY_SIZE);
aus der unten eingefügten Klassendeklaration
using namespace std;
class TCPSocket
{
public:
#define SEND_BUFFER_LENGTH 80
#define DIRECTORY_SIZE 8192
struct sockaddr_in myAddress, clientAddress;
TCPSocket(int port, bool vOutput, const int DIRECTORY_SIZE);
void buildTCPSocket(int newPort);
void processMessage(char* bufferIn, int currentTCPSocket, int tcpSocket, bool verboseOutput);
int getSocket1();
int getSocket2();
Ist entweder die Define oder die Konstruktordefinition ein offensichtlicher Fehler?
Edit: Ok, also für diejenigen von Ihnen, die Jahre in der Zukunft lesen, hier die korrigierte Konstruktordeklaration:
TCPSocket(int port, bool vOutput);
Dann wurde die definierte DIRECTORY_SIZE in der Konstruktordefinition verwendet.
Antworten:
7 für die Antwort № 1Sie können dies nicht tun:
TCPSocket(int port, bool vOutput, const int DIRECTORY_SIZE);
weil es bedeutet
TCPSocket(int port, bool vOutput, const int 8192);
und dies ist keine legale Syntax. Ich denke du meinst:
TCPSocket(int port, bool vOutput, const int nSize = DIRECTORY_SIZE);