gpt4 book ai didi

c++ - C++ 内核的 Jupyter 笔记本错误 [cling]

转载 作者:行者123 更新时间:2023-12-02 10:29:42 25 4
gpt4 key购买 nike

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

#include <iostream>
using namespace std;

int main() {

int a;
a=9;
cout<<a;
return 0;
}
我收到一个错误 ---> error: function definition is not allowed here
int main() {

最佳答案

在坚持中,您不必编写整个程序代码。它就像一种脚本语言。您只需编写应评估的行。不要写main功能:

#include <iostream>
using namespace std;

int a;
a=9;
cout<<a;
您也可以在 cling 中定义函数,但不允许在同一单元格中写入其他代码。

关于c++ - C++ 内核的 Jupyter 笔记本错误 [cling],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62751544/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com