Okay upon running g++ main.cpp -o services
If i do all this in one class lets say .cpp it works fine, but whenever i divide it into another class i keep getting errors, and i really do not understand why, all i did was move the code to another file, and included it.
I am thrown:
[Admin@shadowrealm ircservices]$ g++ main.cpp -o services
In file included from services.cpp:1:0,
from main.cpp:4:
services.h:23:2: error: âSOCKETâ does not name a type
services.h:24:2: error: âHOSTENTâ does not name a type
services.h:25:2: error: âSOCKADDR_INâ does not name a type
services.h:
#ifndef SERVICES_H
#define SERVICES_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <stdarg.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
class services {
public:
services(); //perhaps init something important here, dunno
~services();
int connect();
private:
SOCKET sock;
HOSTENT* host;
SOCKADDR_IN address;
};
#endif /* SERVICES_H */
services.cpp:
#include "services.h"
services::services()
{
//do nothing
}
services::~services()
{
//TODO: incase crash, log why.
}
int services::connect()
{
return 0;
}
C++ is case sensitive. The right is
sockaddr_in
hostent
If I am not mistaken SOCKET or socket does not name a type at all.