I just downloaded Visual Studio 2013, its my first time to use this compiler,
but I just wanted to test this compiler for first time
and I got an error. can you tell me where is the error?
its suppose that with #ifndef shouldn't give me an error.
/*Data.h
I declared named arr to my array;
in my header cant I declare an array without setting the numbers elements?
coz when I did it it told me error,
however when I used code blocks I could do it but all my program was in one file
*/
#include <iostream>
usingnamespace std;
#ifndef DATE_H
#define DATE_H
int arr[10] = {};
void function();
#endif
/*main.cpp
**********************/
#include "Data.h"
int main(){
function();
cout << endl << endl;
return 0;
}
/*function.cpp
#include "Data.h"
it says that here is the error, that my arr is already defined
***********************/
void function(){
for (int i = 0; i < 10; i++){
arr[i] = i + 1;
cout << arr[i] << " ";
}
}
/*Error 1 error LNK2005: "int * arr" (?arr@@3PAHA) already defined in function.obj
Error 2 error LNK1169: one or more multiply defined symbols found*/
when I put constint arr[10]={}; it works but there is another error, it doesn't let me to change the values coz its constant obviously -.-.