VS2015引发了异常:读取访问权限冲突pNode是nullptr

博客内容涉及到在VS2015中遇到的一个异常问题,即在解析XML文件过程中遇到读取访问权限冲突,原因是变量pNode为nullptr。代码展示了XML解析的相关类和方法,包括startElement、endElement和textHandler,但并未给出具体的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

VS2015引发了异常:读取访问权限冲突pNode是nullptr

在这里插入图片描述
在这里插入图片描述
#include “WidgetScenceXmlParse.h”
#include “Game/Script/utility.h”
#include “Game/Script/ScriptData.h”
#include “Game/Script/utility.h”
#include “WidgetManager.h”
#include “WidgetSkinXMLparse.h”
#include “Game/Script/SoundFun.h”
#include “WidgetFun.h”

USING_NS_CC;

WidgetScenceXMLparse::WidgetScenceXMLparse( std::string xmlFileName,cocos2d::Node* pNode)
{
m_pAddNodes.push_back(pNode);
m_pRootNode = pNode;

WidgetUserInfo* pUserInfo = new WidgetUserInfo;
pUserInfo->bRoot = true;
pNode->setUserObject(pUserInfo);//光标在这一行

SAXParser parser;
parser.setDelegator(this);
std::string kFullPath = utility::FullPath(xmlFileName);
parser.parse(kFullPath.c_st
#include <iostream> using namespace std; template<class T> class List { public: List() :pFirst(nullptr) {} //构造函数 void Add(T& val) { Node* pNode = new Node; pNode->pT = &val; pNode->pNext = pFirst; pFirst = pNode; } //在Link表头添加新结点 void Remove(T& val) { Node* pNode = pFirst; Node* pPrev = nullptr; while (pNode) { if ((pNode->pT) == val) { if (pPrev) { pPrev->pNext = pNode->pNext; } else { pFirst = pNode->pNext; } delete pNode; return; } pPrev = pNode; pNode = pNode->pNext; } } //在Link中删除含有特定值的元素 T Find(T& val) { Node* pNode = pFirst; while (pNode) { if ((pNode->pT) == val) { return pNode->pT; } pNode = pNode->pNext; } return nullptr; } //查找含有特定值的结点 void PrintList() { Node pNode = pFirst; while (pNode) { std::cout << (pNode->pT) << std::endl; pNode = pNode->pNext; } } //打印输出整个链表 ~List() { Node pNode = pFirst; while (pNode) { Node* pNext = pNode->pNext; delete pNode; pNode = pNext; } } protected: struct Node { Node* pNext; T* pT; }; Node* pFirst; //链首结点指针 }; class Student { private: std::string name_; int id_; public: Student(const std::string& name, int id) :name_(name), id_(id) {} bool operator==(const Student& other) const { return id_ == other.id_; } friend std::ostream& operator<<(std::ostream& os, const Student& student); }; std::ostream& operator<<(std::ostream& os, const Student& student) { os << "Name: " << student.name_ << ", ID: " << student.id_; return os; } int main() { List<Student> classList; Student s1("张三", 1001); Student s2("李四", 1002); Student s3("王五", 1003); //添加学生 classList.Add(s1); classList.Add(s2); classList.Add(s3); //打印学生 classList.PrintList(); std::cout << std::endl; //查找学生 Student s4("李四", 1002); Student* pStudent = classList.Find(s4); if (pStudent) { std::cout << "Found student: " << *pStudent << std::endl; } else { std::cout << "Student not found." << std::endl; } std::cout << std::endl; //删除学生 classList.Remove(s2); classList.PrintList(); return 0; }请见查找学生进行完善
05-28
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值