A
arnuld
this is the code which runs without any trouble:
-----------------------------------------------------
#include <iostream>
#include <string>
#include <vector>
struct Entry {
std::string name;
int e_num;
};
Entry phone_book[10];
void print_entry(int i) {
std::cout << phone_book.name
<< " "
<< phone_book.e_num
<< "\n";
}
int main() { }
-----------------------------------------------------------
now if i wrap the "whole-thing" above /main/ into a function or if i
put the "whole-thing" above main into the /main/ i got this error:
03_371.cpp: In function 'void c_style_code()':
03_371.cpp:16: error: a function-definition is not allowed here before
'{' token
why exactly i got that?
-----------------------------------------------------
#include <iostream>
#include <string>
#include <vector>
struct Entry {
std::string name;
int e_num;
};
Entry phone_book[10];
void print_entry(int i) {
std::cout << phone_book.name
<< " "
<< phone_book.e_num
<< "\n";
}
int main() { }
-----------------------------------------------------------
now if i wrap the "whole-thing" above /main/ into a function or if i
put the "whole-thing" above main into the /main/ i got this error:
03_371.cpp: In function 'void c_style_code()':
03_371.cpp:16: error: a function-definition is not allowed here before
'{' token
why exactly i got that?