I'm a beginner in C ++ programming and I came across a problem when I tried to run my code in atom , using the gpp-compiler package and MinGW: 'function' was not declared in this scope l.8). I did not understand the reason for the error, can anyone help me?
Here is the main function:
#include <iostream>
#include "header.hpp"
using namespace std;
int main(){
int* a;
a = function(50);
for(int d = 0; d < a.length; d++){
.
.
.
}
system("pause");
return 0;
}
and the header file:
#ifndef FUNCTIONS_H_INCLUDED
#define FUNCTIONS_H_INCLUDED
#include <vector>
int* function(int num){
std::vector<int> c;
.
.
.
int z[(int)c.size()];
for(int b = 0; b < (int)c.size(); b++){
z[b] = c.at(b);
}
return z;
}
#endif
To be more specific, the error message was as follows:
... \ main.cpp: In function 'int main ()':
... \ main.cpp: 9: 18: error: 'function' was not declared in this scope
a = function (50);... \ main.cpp: 10: 23: error: request for member 'length' in 'a', which is of non-class type 'int *' for (int d = 0; d