i´m having this error.
My header:
libtorrent::fingerprint a("LT", LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR, 0, 0);
class TorrentClass
{
}
The compiler complains that libtorrent::fingerprint a already defined in another class, because it has been inclused. So i move it to inside my class
class TorrentClass
{
private:
libtorrent::fingerprint a("LT", LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR, 0, 0);
}
But then my compiler get very strange errors over that moved line, like
error C2059: syntax error : 'string'
What i´m doing wrong ?
In your .h file. Declare this:
In your .cpp (.cc) file. Define the objects:
Also, on my team, we explicitly disallow “global objects” such as the instance of “a” you have declared. The reason being is that the constructor runs before “main” (in a non-deterministic order with all the other global objects). And it’s destructor doesn’t run until after main exits.
If you really need “a” to be global, instantiate it as a pointer and allocate it with new: