【问题标题】:Jupyter notebook error for C++ Kernel[cling]C++ 内核的 Jupyter 笔记本错误 [cling]
【发布时间】:2020-07-06 07:51:26
【问题描述】:

我已经安装了 Cling 内核以便在 Jupiter notebook 中使用 C++ 但是在实现代码之后

#include <iostream>
using namespace std;

int main() {

  int a;
  a=9;
  cout<<a;
  return 0;
 }

我收到一个错误 ---> error: function definition is not allowed here int main() {

【问题讨论】:

    标签: c++ jupyter-notebook anaconda conda cling


    【解决方案1】:

    在紧贴中,您无需编写整个程序代码。它就像一种脚本语言。您只需编写应该评估的行。不要写main函数:

    #include <iostream>
    using namespace std;
    
    int a;
    a=9;
    cout<<a;
    

    你也可以在 cling 中定义函数,但是你不能在同一个单元格中写入其他代码。

    【讨论】:

    最近更新 更多