C ++内核的Jupyter笔记本错误[cling] [英] Jupyter notebook error for C++ Kernel[cling]

查看:89
本文介绍了C ++内核的Jupyter笔记本错误[cling]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Jupiter Notebook中安装了使用C ++的cling内核但是在执行代码之后

I have installed cling kernel for using C++ in Jupiter notebook but after implementing the code

#include <iostream>
using namespace std;

int main() {

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

我收到错误消息--->错误:此处不允许使用函数定义int main(){

I am getting an error as ---> error: function definition is not allowed here int main() {

推荐答案

在这种情况下,您不会编写整个程序代码.就像脚本语言一样.您只需编写应评估的行.不要编写 main 函数:

In cling you don't write the whole program code. It's like a script language. You just write the lines that should be evaluated. Don't write the main function:

#include <iostream>
using namespace std;

int a;
a=9;
cout<<a;

您还可以在保全中定义函数,但是不允许将其他代码写入同一单元格.

You can also define functions in cling but then you are not allowed to write other code into the same cell.

这篇关于C ++内核的Jupyter笔记本错误[cling]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆