xeus-cling
xeus-cling copied to clipboard
function definition is not allowed here
Hi I have searched many issues over your github telling the same story, still, I was wondering to know if there is any update or solution for my problem:
#include <iostream>
#include <string>
using namespace std;
const int MAX = 1000;
int EditDistance(string A, string B) {
cout << A << B << endl;
}
int main(int argc, char* argv[]){
string A, B;
cin >> A;
cin >> B;
cout << EditDistance(A, B);
return 0;
}
error:
input_line_25:4:38: error: function definition is not allowed here
int EditDistance(string A, string B) {
^
input_line_25:7:33: error: function definition is not allowed here
int main(int argc, char* argv[]){
^
Interpreter Error:
just to mention that all of the code lines are in a same cell.
Regards
Quick note, unrelated to this issue:
You don't need to specify main
in xeus-cling.
I'm having the same problem. @SylvainCorlay how woud you refactor the above code to make it work?
You first need to get rid of the main
function, you can see the entire Notebook as the main
. And if you get an error: function definition is not allowed here
, please be sure to define your function in a separate cell with no code before the definition.
Thanks.