sry for lame data structure but had to take like that
i've included it in my main.cpp
and thr's another header "simulate.h"
that needs to be included in "main.cpp"
now the problem is i have to include "shapes.h" in "simulate.h" too.. but when i do that i get error
1>simulate.obj : error LNK2005: "struct polygon pg" (?pg@@3Upolygon@@A) already defined in main.obj
1>simulate.obj : error LNK2005: "struct circles cl" (?cl@@3Ucircles@@A) already defined in main.obj
1>editor/Debug\editor.exe : fatal error LNK1169: one or more multiply defined symbols found
i tried removing "shapes.h" from "main.cpp" with "simulate.h" included in "main.cpp" and "shapes.h" included in "simulate.h" but still get the same error.
There are two ways to deal with this. One is to put the word "extern" in front of the declarations in the header file and then in one and ONLY one place (main.cpp most likely) add those declarations again without the "extern" in front of them.
The second option is to do this -
In the header file :
#define GLOBAL extern
// define structures here ...// now declare instances
GLOBAL circles cl;
GLOBAL polygon pg;
Then in just ONE of the .cpp files, again like main.cpp, do this :
This scheme can work with virtually any global variables if you really need to use them.
If you have an unresolved external error from the linker then you did not do what I said to exactly. Copy and paste the two definitions I showed in the previous post and put them where I said they need to go and it should work fine. I have used this technique for a long time with several different compilers and not had any problems.
It is not a good idea to create global variables inside a header file.
So create a shapes.cpp file and put the global variables inside them.
In the shapes.h header file put the extern keyword before the global variable creation statement as mentioned in the other posts.
«_Superman_» I love work. It gives me something to do between weekends.
Is this a "feature" of VC 6.0 only?
The associated list box puts the scroll bar on the right and aligns the text on right also.
Now the user have to select the list box from left and select from the list box on right.
It is not a major problem, but...
Only constructive comments to the subject will be appreciated.
No lectures please.
as i know and read some where there i found if file is created through admin then generally limited user cann't write in file.Ony Limited user have read permission.So can i change file attribute for limited user or there is any rule for create a file for all user read and write permission then please help me.