简体   繁体   中英

c++ newbie error C2512: no appropriate default constructor available

im new to c++ and I wanted to call a class/function from a second .cpp page.

error:

error C2512: 'QueryAuthServer' : no appropriate default constructor available

new.h

class QueryAuthServer : public CNtlSession
{
public:
    void SendCharLogInRes(CNtlPacket * pPacket);
}

new.cpp

void QueryAuthServer::SendCharLogInRes(CNtlPacket * pPacket)
{
    ....
}

main.cpp

QueryAuthServer C;
C.SendCharLogInRes(pPacket);

The error is at the main.cpp I already used google and viewed othr pages with the same error but I dont understand how to solve the bug. Ive read, that something about "C" should be missing but I dont know what..

If your base class - CNtlSession does not have a default contructor, then the compiler will not be able to automatically generate a default contructor for your derived class - QueryAuthServer . If you need one, you have to write it yourself, indicating exactly how you want your base class subobject initialized.

class QueryAuthServer : public CNtlSession
{
public:
    QueryAuthServer() :CntlSession(/*PROVIDE ARGUMENTS HERE!*/)
    {
    } 
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM