By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,514 Members | 1,832 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,514 IT Pros & Developers. It's quick & easy.

Compile error: no appropriate default constructor available

P: n/a
Ook
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(){};
Oct 29 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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<int> .

--

Valentin Samko - http://www.valentinsamko.com
Oct 29 '05 #2

P: n/a
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
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<int>

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.
{
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

Oct 29 '05 #3

P: n/a
Ook

"Valentin Samko" <c+***********@digiways.com> wrote in message
news:43***********************@authen.white.readfr eenews.net...
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<int> .

--

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>
.....
Oct 29 '05 #4

P: n/a
* "Ook" <Ook Don't send me any freakin' spam at zootal dot com delete
the Don't send me any freakin' spam>:
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(){};


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?
Oct 29 '05 #5

P: n/a
Ook wrote:
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 <typename T>
class DList
{
public:
DList(){};
};
template <typename T>
class Polynomial2 : public DList<T>


Yes, in both cases you specify the type.

--

Valentin Samko - http://www.valentinsamko.com
Oct 29 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.