no instance of constructor matches the argument list

Ra' Shon Burns 20 Reputation points
2023-06-17T16:10:41.0633333+00:00

Hello,

I have 3 files: <code>beans</code>

Window.h has declarations for a class named WindowClass:

class WindowClass
{
public:
	WindowClass(UINT Style,
		HINSTANCE hInstance,
		HICON Icon, HCURSOR Cursor,
		HBRUSH Background, LPCTSTR MenuName,
		LPCTSTR className, HICON IconSm);
	~WindowClass();
	bool Register();
private:
	WNDCLASSEX m_wc;
};

Window.cpp has definitions for the class WindowClass:

WindowClass::WindowClass(UINT Style,
	HINSTANCE hInstance,
	HICON Icon, HCURSOR Cursor,
	HBRUSH Background, LPCTSTR MenuName,
	LPCTSTR className, HICON IconSm)
{
	m_wc.cbSize = sizeof(WNDCLASSEX);
	m_wc.style = Style;
	m_wc.lpfnWndProc = DefWindowProc;
	m_wc.cbClsExtra = 0;
	m_wc.cbWndExtra = 0;
	m_wc.hInstance = hInstance;
	m_wc.hIcon = Icon;
	m_wc.hCursor = Cursor;
	m_wc.hbrBackground = Background;
	m_wc.lpszMenuName = MenuName;
	m_wc.lpszClassName = className;
	m_wc.hIconSm = IconSm;
}
WindowClass::~WindowClass()
{
}
bool WindowClass::Register()
{
	return RegisterClassEx(&m_wc);
}

WinMain.cpp is the window initializer:

int WINAPI wWinMain(HINSTANCE MainInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
WindowClass MainWndClass(NULL, MainInstance,
LoadIcon(MainInstance, IDI_APPLICATION),
LoadCursor(MainInstance, IDC_ARROW),
NULL, NULL,
"Main Window Class",
LoadIcon(MainInstance, IDI_APPLICATION));
Window MainWindow;
}

however, i'm getting this error:

Severity Code Description Project File Line
Error (active) E0289 no instance of constructor "WindowClass::WindowClass" matches the argument list [redacted] C:[redacted]\WinMain.cpp 5
Windows development | Windows API - Win32
Windows for business | Windows Client for IT Pros | User experience | Other
Developer technologies | C++
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 90,686 Reputation points
    2023-06-17T17:49:20.0433333+00:00

    You declared : LPCTSTR className

    So, use : L"Main Window Class"

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.