OK, lets see I am trying to use a ONE structure with multiple .cpp's (which I got to work just not the right way). I initialized my structure in my header file. I trying to find a way to save a value in a int or string from the structure and then be able to output the value of the struct variable in another .cpp... I search for about 2 hours on google and the boards themselves ( Im not to good at searching for stuff )... I did end up figuring out how to have 2 different values with the same name but not a way to have one with same name over the span of multiple .cpp's. any help is greatly appreciated (BELOW is a small sample program I made to try this ( it doesnt work the way I want tho ))
This is my header
Code:
#include <iostream>
#include <windows.h>
#include <fstream>
using namespace std;
void menu();
void load();
void newg();
int main();
struct test {
int tst;
};
test tet;
This is one .cpp
Code:
#include "all.h"
int main()
{
cout << "choose a value for tst" << endl;
cin >> tet.tst;
cin.get();
menu();
}
This is my other .cpp
Code:
#include "all.h"
void menu()
{
cout << "tst Value you chose" << tet.tst << endl;
cin.get();
}
and this is the error that I get
Code:
.objs\main.o:main.cpp:(.bss+0x0): multiple definition of `tet'
Thanks again for any help you provide