qq_58666039 2021-11-12 09:42 采纳率: 50%
浏览 37
已结题

疑似空指针的错误,有没有人看看 help 球求了

img

我调用堆栈查看错误

img

head是我定义的一个PBC类的一个指针

img

PBC类的具体代码:
头文件

#pragma once

class PBC
{
public:
    PBC(void);
    ~PBC(void);
    PBC(string name,int time,int Runtime,int priority,char state,PBC* next);//构造函数
public:
    string name;//进程名
    int time;
    int Runtime;//运行时间
    int priority;//优先级
    char state;//状态
    PBC* next;//指向下一个进程
};

具体实现

#include "StdAfx.h"
#include "PBC.h"

PBC::PBC(void)
{
    name="0",time=0,Runtime=0,priority=0,state=NULL,next=0;
}
PBC::~PBC(void)
{
}
PBC::PBC(string name,int time,int Runtime,int priority,char state,PBC* next)
{
    this->name=name;
    this->time=time;
    this->Runtime=Runtime;
    this->priority=priority;
    this->state=state;
    this->next=next;
}
  • 写回答

2条回答 默认 最新

  • greatofdream 2021-11-12 10:00
    关注

    head需要初始化一个PBC对象后才能使用里面的成员变量name等

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 11月20日
  • 已采纳回答 11月12日
  • 创建了问题 11月12日