簡體   English   中英

C ++錯誤:??? 沒有命名類型

[英]c++ error: ??? does not name a type

在運行g ++ main.cpp -o服務后還可以

如果我在一個類中完成所有操作,可以說.cpp可以正常工作,但是每當我將其划分為另一個類時,我都會收到錯誤消息,而且我真的不明白為什么,我所做的就是將代碼移到另一個文件中,並且它。

我被拋出:

[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 ++區分大小寫。 右邊是

sockaddr_in
hostent

如果我沒有記錯的話,SOCKET或套接字根本不會命名類型。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM