|
Yes, it is better not to declare variable inside the headers.
I was pointing out, when the header is included in the c file, it become a single translation unit. So, the unit already has the variable. Then there is no extern is required.
|
|
|
|
|
Rejeesh.T.S wrote: Yes, it is better not to declare variable inside the headers.
I think you are confusing declaring with defining.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Thanks for correcting. I would have mentioned "defining". 
|
|
|
|
|
You have it backwards.
Your extern node_t *root; belongs in your .h file. It declares to anyone that includes it that there is such a variable that is created someplace and can be used.
Your node_t *root = 0; belongs in exactly one .c file and no .h file. It defines (creates) the variable. You only do this once. If you put this in a header file, than each .c file that uses that header would create a separate variable of that name. Those multiple variables of the same name which are globally visible and accessible would conflict with each other, hence the error multiple definition of `root'
|
|
|
|
|
Hi Guys i have a member function and a variable .. while accessing member function can we have access the variable also....
vikas da
|
|
|
|
|
Can you show with some sample code what you are trying to do. I really didn't get your question.
|
|
|
|
|
tasumisra wrote: Hi Guys i have a member function and a variable .. while accessing member function can we have access the variable also....
If you have also a C++ book, please read it.
On the serious side: read the f#*?in' book!
There are some rules about information hiding in C++ , and what you said doesn't help us answering the question.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
If you couldn't... you wouldn't be able to use Get/Set functions (a.k.a = accessing a function that access the variable)
If that is not the answer you expected, then ask something a bit quite more concrete
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Nelek wrote: f that is not the answer you expected, then ask something a bit quite more concrete
May I have a sir (plz plz urgenz)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Yes of course you may have it, but not drink it
drinking is not allowed at job
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Nelek wrote: drinking is not allowed at job
Nah, they allow me drinking here. They know, when drunk, I'm more productive...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I am stuck in the issue. When I run a multi threaded windows service during process I got following error message:
"Microsoft Visual C++ Runtime Library
Runtime Error
This application has requested the Runtime to terminate it in an unusual way. Please contact the applications support team for more information. "
The OS is Microsoft windows xp 2002 sp3. Plz tell me how can i troubleshoot the problem. What could be the cause. How can I find the problematic code?
Thanks for your time.
|
|
|
|
|
bilal haider wrote: Plz tell me how can i troubleshoot the problem.
Use your debugger to track down the problem.
|
|
|
|
|
ofetn a multi-thread versus single thread linking issue
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Hi,
I developed my application in VS2008,.Net framework version 3.5 SP1.
Its runs in my machine.But when i run it in another machine its not running.It shows the error
This application has failed to start because the application configuration is incorrect.Reinstalling the application may fix the problem
In that machine VC++6.0 is installed.
How can i avoid this error?
I have to send this applciation to client.I dont know whether they have VS2008
Anu
|
|
|
|
|
|
I have a third-party DLL,which is a regular MFC DLL. When I use LoadLibrary to load it, the handle returned always is NULL.I use dependecy to parser it, which report MSVCR80D.dll and MSJAVA.dll not find. How to resolve this problem.
|
|
|
|
|
Is it failing in your development machine? MSVCR80D.dll is a debug version DLL.
|
|
|
|
|
Yes. I use debug version DLL in my debug enviroment.I debug my code and found LoadLibrary always return NULL. I use the same compiler as the DLL.
|
|
|
|
|
Can you try GetLastError() to see the cause of failure?
|
|
|
|
|
I have use try-catch to catch exception, but no exception throw.
|
|
|
|
|
You can include following code after your LoadLibrary() call to get the error code:
DWORD dwErr = GetLastError();
And check the dwErr value in Visual Studio Error Lookup tool which is available under 'Tools' menu.
|
|
|
|
|
I try it. error no is 126, error openning file.
|
|
|
|
|
It seems as you figured out, the depending DLL is missing. Can you check if everything works fine on Release version?
|
|
|
|