Hi guys, I'm trying to run the following code, but it seems there has to be a mistake in the main() part of the program. Every time I build the program, I receive the error 'function definition is not allowed here'. Can someone help me?
Examine the function definitions void Algorithme::read() and void Algorithme::adjmatrix()
Verify that braces are matched; that for every opening brace {, there is a corresponding closing brace }
#include <iostream>
#include <fstream>
#include <cstring>
#include <string>
usingnamespace std;
class Algorithme {
private:
int i = 0;
struct milestone {
int milestone_x;
int milestone_y;
char milestone_name[6];
};
int nb = 12;
milestone node[12];
struct process {
char process_name[20];
float process_consomation;
char process_node1[6];
char process_node2[6];
};
process procedure[17];
public:
void read();
void adjmatrix();
};
void Algorithme::read()
{
//...
}
void Algorithme::adjmatrix()
{
//...
}
int main()
{
Algorithme answer;
answer.read();
answer.adjmatrix();
return 0;
}
And just in case, you need to be clear about which C++ standard your code conforms to.
1 2 3 4 5 6 7 8
$ g++ foo.cpp
foo.cpp:10:11: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
int i = 0;
^
foo.cpp:18:12: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
int nb = 12;
^
$ g++ -std=c++11 foo.cpp