标题:qt中invalid use of member(did you forget &)
只看楼主
看uin
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2014-1-6
 问题点数:0 回复次数:0 
qt中invalid use of member(did you forget &)
#include "qqserver.h"
#include "ui_qqserver.h"
#include <stdio.h>
#include <pthread.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <QTextCodec>

QVector<Client> c(50);
int sockfd;
int size=0;
char* IP="127.0.0.1";
short PORT=10000;

QQServer::QQServer(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::QQServer)
{
    ui->setupUi(this);
    init();
}

QQServer::~QQServer()
{
    delete ui;
}

void QQServer::init()
{
    ui->show_text->setText(tr("服务器开始启动。。。"));
    sockfd=socket(AF_INET,SOCK_STREAM,0);
    if(sockfd==-1){
        ui->show_text->append(tr("创建socket失败"));
        ui->show_text->append(tr("服务器启动失败"));
        exit(-1);
    }
    struct sockaddr_in addr;
    addr.sin_family=AF_INET;
    addr.sin_port=htons(PORT);
    addr.sin_addr.s_addr=inet_addr(IP);
    //绑定socket和通信地址
    if(bind(sockfd,(struct sockaddr*)&addr,sizeof(addr))==-1){
        ui->show_text->append(tr("绑定失败"));
        ui->show_text->append(tr("服务器启动失败"));
        exit(-1);
    }
    ui->show_text->append(tr("设置监听成功"));
    ui->show_text->append(tr("初始化服务器成功"));
}

void QQServer::sendMsgToAll(char* msg)
{
    int i=0;
    for(;i <size ;i++)//这行报错
    {
        if(c[i].fds!=0){
            send(c[i].fds,msg,strlen(msg),0);
        }
    }
}
搜索更多相关主题的帖子: invalid include member parent 
2014-01-10 22:38



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-426389-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028336 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved