Ok, this has got me banging my head against a wall. I have a structure defined in a header file. It get initialized in my "main.cpp" file, then later in a separate file "readconfig.cpp" it gets accessed to store information. I haven't been able to get it to compile except by using the following code, which segfaults. I was wondering if anyone here could assist me in this problem.
Here is the revelant main.h code:
#ifndef _MAIN_H
#define _MAIN_H
...
struct _aline { //Admin Line
std::string provider;
std::string serverdesc;
std::string admin;
};
...
#endif
main.cpp:
#include "main.h"
int main()
...
_aline *aline = new _aline;
aline->provider = "HURR DURR";
...
and readconfig.cpp:
bool ReadConfig()
...
_aline *aline;
cout<<"Aline: \n";
cout<<aline->provider<<"\n";
...
I've tried to get this code to compile, but so far this is the only way I can get it to. If I try to move the statement in readconfig.cpp to main.h I get linker errors like there's no tomorrow.
Any help is greatly appreciated.