 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Ook Guest
|
Posted: Sat Oct 29, 2005 6:07 pm Post subject: Compile error: no appropriate default constructor available |
|
|
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
|
Posted: Sat Oct 29, 2005 6:10 pm Post subject: Re: Compile error: no appropriate default constructor availa |
|
|
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
|
Posted: Sat Oct 29, 2005 6:14 pm Post subject: Re: Compile error: no appropriate default constructor availa |
|
|
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
|
Posted: Sat Oct 29, 2005 6:33 pm Post subject: Re: Compile error: no appropriate default constructor availa |
|
|
"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
|
Posted: Sat Oct 29, 2005 6:35 pm Post subject: Re: Compile error: no appropriate default constructor availa |
|
|
* "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
|
Posted: Sat Oct 29, 2005 6:57 pm Post subject: Re: Compile error: no appropriate default constructor availa |
|
|
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 |
|
 |
|
|
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
|
|