Error C2512 No Appropriate Default
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the error c2512 no appropriate default constructor available c++ workings and policies of this site About Us Learn more about error c2512 visual c++ Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions caple c2512 Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
No Appropriate Default Constructor Available C++
Join them; it only takes a minute: Sign up Why I am getting error c2512 : no appropriate default constructor availiable? [closed] up vote -2 down vote favorite I am trying to implement the templated class MyQueue(Logical structure is ring buffer): // MyQueue.h #pragma once template
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about no appropriate default constructor available qt Stack Overflow the company Business Learn more about hiring developers or posting ads with
'uuserwidget' : No Appropriate Default Constructor Available
us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is
C++ No Default Constructor Exists For Class
a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up c++ newbie error C2512: no appropriate default constructor available up vote 1 down http://stackoverflow.com/questions/15534744/why-i-am-getting-error-c2512-no-appropriate-default-constructor-availiable vote favorite 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 http://stackoverflow.com/questions/24182687/c-newbie-error-c2512-no-appropriate-default-constructor-available error but I dont understand how to solve the bug. Ive read, that something about "C" should be missing but I dont know what.. c++ share|improve this question edited Jun 12 '14 at 11:02 David 1,2351610 asked Jun 12 '14 at 10:58 user3733748 1513 add a comment| 1 Answer 1 active oldest votes up vote 5 down vote accepted 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!*/) { } }; share|improve this answer answered Jun 12 '14 at 11:02 Armen Tsirunyan 76.4k32215343 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service. Not the answer you're looking for? Browse other questions tagged c++ or ask your own questio
available Visual Studio https://social.msdn.microsoft.com/Forums/vstudio/en-US/493d5a15-0e84-449c-a8d8-fa27523ce1b8/help-strange-error-c2512-no-appropriate-default-constructor-available?forum=vclanguage Languages , Windows Desktop Development > C++ Standards, Extensions, and Interop Question 0 Sign in to vote I'm working in VC2005. The error appears as shown by comment below:CLogStream::CLogStream ( const char* logFile, unsigned short level, long logFileLimit ) : logLevel (level), curLimit (1), m_ringBuffer (0), m_ringBufferLogLevel (3), m_ringBufferFlushLevel (1) {//error message points to this line CheckLogFile(logFile, logFileLimit); logBuf.open(logFile, ios::out); init(&logBuf); m_configIf = NULL; } CLogStream::CLogStream () : ostream(&logBuf), logLevel (0), curLimit (1), m_ringBuffer (0), m_ringBufferLogLevel (3), m_ringBufferFlushLevel (1) { } and in its corresponding head file. I've defined constructors as follows:class CLogStream : public ostream { //...blah, blah public: CLogStream (const char* logFile, unsigned short level = 0, long logFileLimit = 50000); //...blah, blah CLogStream (); ~CLogStream() { } //...blah, blah } Since there's only no appropriate one error message, the implementation of the default constructor seems ok.I don't understand how comes that error. BTW, it works ok in VC6.Could anyone help? Thanks in advance. Tuesday, December 16, 2008 2:43 PM Reply | Quote Answers 0 Sign in no appropriate default to vote You're getting that error because one of the members (or base classes) of your CLogStream class does not have a default constructor, and you haven't initialized that member in your CLogStream constructor's initializer list.For example:class A{ public: A(int dummy);};class B{ public: B(); private: A myA;};B::B() : myA (42) // 'myA' must be initialized here because A has no default constructor{} Marked as answer by NEske Tuesday, December 16, 2008 3:10 PM Tuesday, December 16, 2008 2:54 PM Reply | Quote All replies 0 Sign in to vote You're getting that error because one of the members (or base classes) of your CLogStream class does not have a default constructor, and you haven't initialized that member in your CLogStream constructor's initialize