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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:03:38+00:00 2026-06-03T21:03:38+00:00

I am having a problem with that No appropriate default constructor available error, and

  • 0

I am having a problem with that “No appropriate default constructor available” error, and it is probably just ONE TINY thing that I am missing. I’m pretty new to C++, but I’m slowly getting it.

As I understand, C++ will create a default constructor if you don’t specify any constructors. However, I get the error even though I have not specified any constructors. I’ve tried googling solutions to this, but everyone else is either extending a class wrong or HAVE specified constructors, hence they get this error. I HAVE NOT specified any constructors, yet I get this error anyway. The DirectXGame class is below.

DirectXGame.h

#include "StdAfx.h"
#include "DirectInputHelper.h"

class DirectXGame
{
public:
    //DirectXGame();

    bool Initialize(HINSTANCE hInstance, HWND windowHandle);
    void ShutDown();

    bool LoadContent();
    void UnloadContent();

    void Update(float timeDelta);
    void Render();

private:
    HINSTANCE progInstance;
    HWND winHandle;

    D3D_DRIVER_TYPE driverType;
    D3D_FEATURE_LEVEL featureLevel;

    ID3D11Device* pDev;
    ID3D11DeviceContext* pDevContext;
    ID3D11RenderTargetView* pBackBufferTarget;
    IDXGISwapChain* pSwapChain;

    DirectXInput::DirectInputHelper inputHelper;
    DirectXInput::KeyboardState* keyboardDevice;
    DirectXInput::MouseState* mouseDevice;

    bool isShutDown;
};

Notice I have not specified any constructor, as they’ve been commented out. The actual error is thrown on the line in the main method where I create a new instance of the class.

DirectXApp.cpp

int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow )
{

    UNREFERENCED_PARAMETER( hPrevInstance );
    UNREFERENCED_PARAMETER( lpCmdLine );

    if( FAILED( InitWindow( hInstance, nCmdShow ) ) )
        return 0;

    //std::auto_ptr<DirectXGame> DirectXGame( new DirectXGame() );
    DirectXGame* game = new DirectXGame(); //The compile error is on this line.


    bool result = game->Initialize(g_hInst, g_hWnd);

    if(!result)
    {
        game->ShutDown();


return -1;
}

// Main message loop
MSG msg = {0};
while(TRUE)
{
    if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);

        if(msg.message == WM_QUIT)
            break;
    }
    else
    {
        game->Update(0.0f);
        game->Render();
    }
}

game->ShutDown();

//Don't forget to delete the game object, as it is a pointer.
delete game;

return static_cast<int>(msg.wParam);

}

I’m probably just missing one of the many small details you have to pay attention to in C++.

  • 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-06-03T21:03:40+00:00Added an answer on June 3, 2026 at 9:03 pm

    You are missing your blank/default constructor, and the compiler cannot guess at how to implement one for you automatically.

    C++ will create a blank constructor for you if it is a trivial (non-complex) class. If your class is descended from another class, then its ancestory must implement default constructors or be trivial in themselves.

    If your class includes other classes, the included classes must either have default constructors defined for them, or they must be trivial in themselves so that the compiler can implement trivial constructors for them as well.

    In your case, the culprit is likely DirectXInput::DirectInputHelper inputHelper; as your class does not have any ancestors, and all your data members are pointers, basic data types, or defined data types other than that one class data variable.

    • 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 that just started happening in OS 3.1. I have
One problem that I am facing is having many queries with similar select statements
I am having problem that when i am trying to submit the form by
HI Guys, Here I am having problem that How can I post an image
I'm having a problem that a statusbar get displayed over the content of the
Essentially, after compiling utility jars w/ ANT, I'm having the problem that all the
I'm having the weird problem that after having javascript inject some dom-elements the css-rules
I'm having a strange problem that is affecting at least some of my international
I'm having a problem with wpf listbox. my problem is that when I add
I'm having a strange problem in that I have php inserting text into 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.