
C++之Debug
文章平均质量分 56
The Gao
这个作者很懒,什么都没留下…
展开
-
Debug:runtime error: reference binding to misaligned address 0xbebebebebebec0b6 for type 【C++】
示例这一debug是我在做力扣206——反转链表,运用堆栈的方法实现时遇到的,如果小伙伴们对这道题没有思路的话,可以看我的博客力扣206:反转链表【C++】,有写这道题的解法。以下是当时遇到问题时的程序段:class Solution {public: ListNode* ReverseList(ListNode* pHead) { stack<ListNode*>stk;//创建堆栈 ListNode* temp=(ListNode*)mallo原创 2021-04-22 14:59:11 · 4984 阅读 · 3 评论 -
Debug:==42==ERROR: AddressSanitizer: heap-buffer-overflow on address【C++】
结论数组越界或堆栈溢出。若使用条件或循环语句,要看极端情况下,条件或循环语句中是否有超过数组或堆栈容量的行为。示例这个debug是我在做力扣739——每日温度时遇到的,如果这道题小伙伴们没有思路的话,可以看我的博客,有写这道题的解法。以下为当时遇到问题时的程序段:vector<int>v;for(int i=0;i<T.size()-1;i++){ int target=i+1; while(T[target]<=T[i]&&target&原创 2021-04-12 15:37:49 · 9080 阅读 · 0 评论 -
Debug:reference to non-static member function must be called【C++】
结论将compare函数改为静态成员函数,即static bool compare(string a,string b){return a+b>b+a;}示例这个debug是我在做力扣179——最大数时遇到的,如果这道题小伙伴们没有思路的话,可以看我的博客,有写这道题的解法。以下为当时遇到问题时的程序段:class Solution {public: bool compare(string a,string b){//排序规则 return a+b>b+a;原创 2021-04-12 21:27:43 · 598 阅读 · 0 评论