首页 > 解决方案 > 我在玩 VS2017 时发现了一些东西

问题描述

当我尝试学习 throw catch 时,我刚刚编译了我的代码,我发现这个输出是什么意思?

    #include "stdafx.h"
    #include <iostream>

    using namespace std;

    void MightGoWrong() {
     bool error = true;

     if (error) {
       throw 8;
     } 
//   -------------------------
     int main()
     {      
        cout << MightGoWrong;               
        return 0;
     }

输出是:012211A4 这是什么意思?

输出

代码

标签: c++visual-studio

解决方案


你没有调用你的函数。

cout << MightGoWrong;只是打印函数的地址。要调用它,您应该这样做cout << MightGoWrong();


推荐阅读