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 7052769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:25:25+00:00 2026-05-28T03:25:25+00:00

I would like to use nested classes as a part of an application I

  • 0

I would like to use nested classes as a part of an application I am building. The first piece of code I have (header file, which I included some code for this question) is the following:

class Window {

public:
    indev::Thunk32<Window, void ( int, int, int, int, void* )> simpleCallbackThunk;
    Window() {
        simpleCallbackThunk.initializeThunk(this, &Window::mouseHandler); // May throw std::exception
    }
    ~Window();

    class WindowWithCropMaxSquare;
    class WindowWithCropSelection;
    class WindowWithoutCrop;

    virtual void mouseHandler( int event, int x, int y, int flags, void *param ) {
    printf("Father");
    }

private:
    void assignMouseHandler( CvMouseCallback mouseHandler );    

};

class Window::WindowWithCropMaxSquare : public Window {

public:
    WindowWithCropMaxSquare( char* name );
    virtual void mouseHandler( int event, int x, int y, int flags, void *param ) {
        printf("WWCMS");
    }

};

class Window::WindowWithCropSelection : public Window {

public:
    WindowWithCropSelection( char* name );
    virtual void mouseHandler( int event, int x, int y, int flags, void *param ) {
        printf("WWCS");
    }

};

class Window::WindowWithoutCrop : public Window {

public:
    WindowWithoutCrop( char* name );
    virtual void mouseHandler( int event, int x, int y, int flags, void *param ) {
        printf("WWOC");
    }

};

Now, I want to instantiate a WindowWithCropMaxSquare class in MAIN and execute the mouseHandler function.

In MAIN I have

Window::WindowWithCropMaxSquare *win = new Window::WindowWithCropMaxSquare("oopa");
win->mouseHandler(1,1,1,1,0);

However, this causes a problem at the linking stage. I got the following error:

Error 1 error LNK2019: unresolved external symbol “public: __thiscall Window::WindowWithCropMaxSquare::WindowWithCropMaxSquare(char *)” (??0WindowWithCropMaxSquare@Window@@QAE@PAD@Z) referenced in function _main c:\Users\Nicolas\documents\visual studio 2010\Projects\AFRTProject\AFRTProject\AFRTProject.obj

So, can anyone please let me know how to address this problem?

  • 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-28T03:25:26+00:00Added an answer on May 28, 2026 at 3:25 am

    You need two things: a body for each constructor, and correct const’ness.

    WindowWithCropMaxSquare( char* name );
    

    is just a declaration without any definition (body). Empty constructor body, as you imply in your comment, would be

    WindowWithCropMaxSquare( char* name ) {}
    

    Also I very much suspect that

    Window::WindowWithCropMaxSquare *win = new Window::WindowWithCropMaxSquare("oopa");
    

    requires a constructor that takes const char* since you are giving it a constant (an rvalue):

    WindowWithCropMaxSquare( const char* name ) {}
    

    or

    WindowWithCropMaxSquare( const string& name ) {}
    

    The compiler will not give a constant as argument to a function that takes non-const since such function is indicating to you that it may modify the given argument, clearly not allowed for a constant.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have nested grids in my views and would like to use same CSS
I have a class that I would like to reference in my header file,
Hey I would like to use Nested Stored Procedures in ASP.NET 2. The first
I would like to learn how I can use nested template tags where the
I am using AdoNetAppender (SQL server) in my asp.net application and would like use
I'm having trouble getting nested areas to work. I would like to use a
Assuming you have a DOM tree with nested tags, I would like to clean
I have two classes that I would like to transform to protobuf messages: [ProtoContract]
Would like to know when it is right to uses a nested classes in
I have recently started using boost::exception. Now I would like to use boost::errinfo_nested_exception to

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.