473,396 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

no appropriate default constructor available

xarzu
88 64KB
What causes the

no appropriate default constructor available

linker error

when I do have an constructor defined in the header file?
Aug 2 '07 #1
2 1264
Banfa
9,065 Expert Mod 8TB
I default constructor is one that can be called without any parameters.

If you provide no constructor the compiler provides a default constructor for you.

However if you provide a constructor and thats parameters then the compiler does not provide a default constructor for you, additionally if at least 1 of those parameters does not have a default value then there is no default constructor for the class.

Sometimes it is necessary to have a default constructor, for instance if you create a list using that class and the type.
Aug 3 '07 #2
RRick
463 Expert 256MB
Your second line describing the appropriate contstructor error sounds like a compiler error but your 3rd line says its a linker error.

My guess is that you have declared the constructor in the header, but you forgot to define the body of the constructor else where. This allows your code to compile but causes the dreaded "undefined external" linker error.
Aug 3 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: news.microsoft.com | last post by:
BUG: struct default constructor is not displayed on intellisense yet it is available, BUG Make a struct type with a parameterized constructor. Try to construct the type in the IDE and...
4
by: Duy Lam | last post by:
The compiler is complaining about "no appropriate default constructor available" when I reference a subclass. The basic setup is that i have a class Test and a subclass called TestKid. I want to...
17
by: highli | last post by:
When a non-default constructor provided in a class, the default constructor is not available anymore. In what cases shall a default constructor be defined explicitly? Specifically, in the...
4
by: stephane | last post by:
I can't make this work it says I dont have a default constructor available. Can someone tell me what's wrong with this please? #include <iostream> using namespace std; #include "points.h" ...
5
by: Ook | last post by:
Here is my code, can some kind soul tell me what I'm doing wrong, or why I get this compile error, and maybe what to do to prevent it? I think I must be missing some fundamental concept here, or...
3
by: Stanislav Simicek | last post by:
Hello, I'm trying to implement "Null-Field" feature (like Stream::Null) in MC++, but I am not able to initialize static member properly due to compiler error C2512 (no appropriate default...
0
by: WithPit | last post by:
I have some problems with the instantiating new objects. For example I have the following code //Headerfile (Texture1D.h> #pragma once #using <mscorlib.dll> #include <osg/Texture1D> #include...
3
by: denis_browne | last post by:
When writing the following code: class Base { Base(const Base &rhs) {} ~Base(); }; void f() { Base b;
74
by: Zytan | last post by:
I have a struct constructor to initialize all of my private (or public readonly) fields. There still exists the default constructor that sets them all to zero. Is there a way to remove the...
3
by: Rahul | last post by:
Hi Everyone, I have the following code and the compiler complains that there isn't any default constructor available, class C { private: C() {
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.