基于2020年10月学期 Object-Oriented Programming 课程 MerkelBot 自动货币交易机的项目,以下列出我遇到过的错误报告及处理方法。
Visual Studio 2019
空屏
等一会儿……项目太大,打开中……
LNK2019 无法解析的外部符号
Solution: 查找 class 中的 static object 是否已在.cpp file中初始化。Define static vectors in .cpp file outside of any of the member functions, bugs disappear.
非静态成员引用必须与特定对象相对
Solution: Make those member functions to be static.
或者建这个 class 的 instantiation 然后使用这个类的实例,而非使用这个类。
注意,使用类时用:: 使用类的实例时用.
MerkelMain::wallet
merkelMain.wallet
C2597 对非静态成员xxx的非法引用
Solution: pass an instance of the class.
Debug assertion failed! Vector subscript out of range
Solution: 检查vector是不是有使用还没存在的那个下标元素的情况,比如输出V[1]但是还没存这个值。
检查是否正确使用了 vector 中的 functions,比如是不是把 vector 当成了array 使用?是不是要使用push_back, erase等等functions?