Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3951038
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:40:56+00:00 2026-05-20T01:40:56+00:00

i´m having this error. My header: libtorrent::fingerprint a(LT, LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR, 0, 0); class TorrentClass

  • 0

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 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:40:56+00:00Added an answer on May 20, 2026 at 1:40 am

    In your .h file. Declare this:

    #ifndef CLASS_TORRENT_H
    #define CLASS_TORRENT_H
    #include "libtorrent.h" // I'm guessing this is the header file that declares the "fingerprint" class
    extern libtorrent::fingerprint a;
    class TorrentClass
    {
    public:
       TorrentClass();
       // your class declaration goes here
    };
    
    #endif
    

    In your .cpp (.cc) file. Define the objects:

    #include "ClassTorrent.h" // the header file described above
    libtorrent::fingerprint a("LT", LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR, 0, 0);
    TorrentClass::TorrentClass()
    {
      // your constructor code goes here.
    }
    

    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:

    libtorrent::fingerprint *g_pFingerPrintA;
    int main()
    {
        g_pFingerPrintA = new libtorrent::fingerprint("LT", LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR, 0, 0);
    
        // program code goes here
    
        // shutdown
        delete g_pFingerPrintA;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am having a problem creating RMIserver class because i keep getting this error
I am having an error that is occurring sporadically. When I encounter this error,
I'm getting a compiler error with this header file: #ifndef GAME1_H #define GAME1_H #include
I am having this error in my j2ee web application. java.sql.SQLException: ORA-00604: error occurred
I`m having the following error . Why am I having this error and how
having sorted this error - Ruby mysql2 Error I now am recieving this error
I am having this odd error with my code. I am trying to troubleshoot
I am having this bizarre error and I don't know what to do. This
I'm having problems figuring out how to fix this error. The following code snippet
I keep getting this error with HG (Mercurial), it seems like it's having a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.