简体   繁体   中英

Jupyter notebook error for C++ Kernel[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;
 }

I am getting an error as ---> error: function definition is not allowed here int 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM