C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Compile error: no appropriate default constructor available

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Ook
Guest





PostPosted: Sat Oct 29, 2005 6:07 pm    Post subject: Compile error: no appropriate default constructor available Reply with quote



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 maybe the syntax is just not
quite right?

template <typename T>
class DList
{
public:
DList(){};
};
class Polynomial2 : public DList
{
public:
Polynomial2(){};
};
int main()
{
return 0;
}

I'm getting compile error:

'DList' : no appropriate default constructor available

at

Polynomial2(){};


Back to top
Valentin Samko
Guest





PostPosted: Sat Oct 29, 2005 6:10 pm    Post subject: Re: Compile error: no appropriate default constructor availa Reply with quote



Ook wrote:
Quote:
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 maybe the syntax is just not
quite right?

template <typename T
class DList
{
public:
DList(){};
};
class Polynomial2 : public DList
{
public:
Polynomial2(){};
};
int main()
{
return 0;
}

DList is a template class, i.e. it requires a template parameter.
Your class Polynomial2 inherits from DList, and you did not specify the template parameter
for DList. For example, you could have
class Polynomial2 : public DList
--

Valentin Samko - http://www.valentinsamko.com

Back to top
Jonathan Mcdougall
Guest





PostPosted: Sat Oct 29, 2005 6:14 pm    Post subject: Re: Compile error: no appropriate default constructor availa Reply with quote



Ook wrote:
Quote:
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 maybe the syntax is just not
quite right?

template <typename T
class DList
{
public:
DList(){};
};
class Polynomial2 : public DList

class DList does *not* exist. A family of classes bearing the name
DList exists and to get one of these classes, you must specify its
template parameters:

class P : public DList
What do you think templates are for? This is such a simple example, and
yet you don't understand it. Either this is too advanced for you, or
your textbook (you do have one, don't you?) is scrap.

Quote:
{
public:
Polynomial2(){};
};
int main()
{
return 0;
}

I'm getting compile error:

'DList' : no appropriate default constructor available

That's a poorly diagnosed message. What this means is that the template
DList must have an argument list.


Jonathan


Back to top
Ook
Guest





PostPosted: Sat Oct 29, 2005 6:33 pm    Post subject: Re: Compile error: no appropriate default constructor availa Reply with quote


"Valentin Samko" <c++.moderated (AT) digiways (DOT) com> wrote

Quote:
Ook wrote:
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 maybe the syntax is
just not quite right?

template <typename T
class DList
{
public:
DList(){};
};
class Polynomial2 : public DList
{
public:
Polynomial2(){};
};
int main()
{
return 0;
}

DList is a template class, i.e. it requires a template parameter.
Your class Polynomial2 inherits from DList, and you did not specify the
template parameter for DList. For example, you could have
class Polynomial2 : public DList
--

Valentin Samko - http://www.valentinsamko.com

Holy moly, 60 seconds and there is an answer here!!! Yes, that is what I was
missing - so, let me make sure I understand. Since Polynomial2 inherits from
DList, then I specify the type of item DList takes, or I make Polynomial2
also a template class so I can do this.

template <typename T>
class DList
{
public:
DList(){};
};
template <typename T>
class Polynomial2 : public DList<T>
.....



Back to top
Alf P. Steinbach
Guest





PostPosted: Sat Oct 29, 2005 6:35 pm    Post subject: Re: Compile error: no appropriate default constructor availa Reply with quote

* "Ook" <Ook Don't send me any freakin' spam at zootal dot com delete
the Don't send me any freakin' spam>:
Quote:
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 maybe the syntax is just not
quite right?

template class DList
{
public:
DList(){};
};
class Polynomial2 : public DList
{
public:
Polynomial2(){};
};
int main()
{
return 0;
}

I'm getting compile error:

'DList' : no appropriate default constructor available

at

Polynomial2(){};

The reason is that you don't use indentation and whitespace in general.

Combined with a compiler that gives you a very misleading error.

The syntax is absolutely not quite right: note that DList is a template
class, then check your usage...

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

Back to top
Valentin Samko
Guest





PostPosted: Sat Oct 29, 2005 6:57 pm    Post subject: Re: Compile error: no appropriate default constructor availa Reply with quote

Ook wrote:
Quote:
DList is a template class, i.e. it requires a template parameter.
Your class Polynomial2 inherits from DList, and you did not specify the
template parameter for DList. For example, you could have
class Polynomial2 : public DList<int> .

Holy moly, 60 seconds and there is an answer here!!! Yes, that is what I was
missing - so, let me make sure I understand. Since Polynomial2 inherits from
DList, then I specify the type of item DList takes, or I make Polynomial2
also a template class so I can do this.

template class DList
{
public:
DList(){};
};
template class Polynomial2 : public DList

Yes, in both cases you specify the type.

--

Valentin Samko - http://www.valentinsamko.com

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.