G
g
hello!
I wanna use a global variable,witch is the best way(I don't want to use
a Singleton for an integer)?
I try :
#ifndef DUMY_H_
#define DUMY_H_
int connections;
#endif /*DUMY_H_*/
#include "dumy.h"
int main()
{
connections=9;
..................
#include "DBconnection.h"
#include "dumy.h"
#include <iostream>
DBconnection:Bconnection()
{
std::cout<<connections<<'\n';
for(int a=0;a<connections;a++)
createConnection();
}
but I get this:
../server.o.bss+0x0): multiple definition of `connections'
../DBconnection.o.bss+0x0): first defined here
any idea?? maybe extern???
thanks.
I wanna use a global variable,witch is the best way(I don't want to use
a Singleton for an integer)?
I try :
#ifndef DUMY_H_
#define DUMY_H_
int connections;
#endif /*DUMY_H_*/
#include "dumy.h"
int main()
{
connections=9;
..................
#include "DBconnection.h"
#include "dumy.h"
#include <iostream>
DBconnection:Bconnection()
{
std::cout<<connections<<'\n';
for(int a=0;a<connections;a++)
createConnection();
}
but I get this:
../server.o.bss+0x0): multiple definition of `connections'
../DBconnection.o.bss+0x0): first defined here
any idea?? maybe extern???
thanks.