Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A simple question about global variable

Status
Not open for further replies.

jayjay60

Programmer
Jun 19, 2001
97
FR
In my application i use ADO method in differents method. So, in each of them when i need of smart pointer as _RecordsetPtr or _ConnectionPtr, i declare them as local variable in each of them. So, i would like to know how and where i could declare the variable so that they would declare one time only. I try to declare them in the .h file or at the top of the .cpp file and it doesn't work, so what is the correct way of doing that?

thanks in advance

jayjay
 
if you want only one for each cpp (not for all) use

namespace
{
declarations here;//will be visible only from this cpp
}
declarations here;//are global. You can
//declare them in other places with keyword extern and
//compiller will look for this one
John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top