惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

A
Arctic Wolf
T
Tenable Blog
T
Troy Hunt's Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Privacy & Cybersecurity Law Blog
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
H
Hacker News: Front Page
S
Secure Thoughts
AWS News Blog
AWS News Blog
L
LINUX DO - 最新话题
D
Darknet – Hacking Tools, Hacker News & Cyber Security
M
MIT News - Artificial intelligence
T
Tor Project blog
S
Schneier on Security
PCI Perspectives
PCI Perspectives
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
美团技术团队
Google DeepMind News
Google DeepMind News
V
Visual Studio Blog
爱范儿
爱范儿
Google DeepMind News
Google DeepMind News
Cyberwarzone
Cyberwarzone
T
The Exploit Database - CXSecurity.com
罗磊的独立博客
T
Threat Research - Cisco Blogs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
V
V2EX
C
CXSECURITY Database RSS Feed - CXSecurity.com
Stack Overflow Blog
Stack Overflow Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
G
GRAHAM CLULEY
L
LINUX DO - 热门话题
D
Docker
J
Java Code Geeks
GbyAI
GbyAI
H
Heimdal Security Blog
The Hacker News
The Hacker News
MongoDB | Blog
MongoDB | Blog
V
Vulnerabilities – Threatpost
T
Tailwind CSS Blog
Cloudbric
Cloudbric
TaoSecurity Blog
TaoSecurity Blog
C
CERT Recently Published Vulnerability Notes
Y
Y Combinator Blog
Recorded Future
Recorded Future
Cisco Talos Blog
Cisco Talos Blog
T
Threatpost
The Register - Security
The Register - Security
Hacker News - Newest:
Hacker News - Newest: "LLM"

博客园 - Samson小天

My researches during my college life. 一些底层的简单东西。 IAT HOOK 实现进程保护 大年初一,总结一下去年的十大事件~ 解决多线程产生的“以前的函数求值超时,函数求值被禁用。必须继续执行才能重新启用函数求值” Guessing Game解题报告 (pku 2328) 分析一道08年10月12日的江苏省程序设计大赛正赛题 数学之美 C# 自定义实体类或集合的自动排序 UltraRun is released 简单的QQ游戏中大家来找茬外挂编写思路 在Vista的UAC下检查程序是否具有Admin权限及应用程序的权限切换 从程序开发角度谈类的封装性。 教你如何解决“线程间操作无效: 从不是创建控件的线程访问它” C#中调用WIN32的API 小记delegate,简单的委托介绍 一个计算简单数学表达式值的算法。 string类型的初值不是随便赋的,记一次奇怪的访问冲突事件 对C#中ADO.NET开发的理解
最近写C++程序时关于GetLastError的感悟。
Samson小天 · 2008-06-30 · via 博客园 - Samson小天

Posted on 2008-06-30 17:16  Samson小天  阅读(3256)  评论(2)    收藏  举报

        最近学校课程设计,于是用C++的工厂模式来写。由于C++没有自动抛出异常,所以只能判断很多东西之后返回一个HRESULT(typedef long HRESULT),如果HRESULT为0则为正常,否则返回错误码。
        这只是一个很平常的设计,但是带来的问题确实巨大的。比如很多东西,比如CreateNode(用于创建链表),其实如果错误返回一个NULL就可以了。但是这样错误码就没法带出了。这时候我们其实可以设计一个公有类,用于返回错误代码。这就是微软为什么有些函数用HRESULT返回,有些一定要用GetLastError()才能得到的原因。
        由于很少写C++,所以这次的课程设计很失败……特写此篇文章,特此勉励自己,希望这个暑假可以好好的学习和深入研究C++。