Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

vector<>::vector(int) in gcc2.95.3

2 views
Skip to first unread message

Joachim Hussong

unread,
Feb 17, 2003, 9:38:04 AM2/17/03
to
Hi,

I am using gcc 2.95.3. I am missing a constructor for std::vector. In
the stl documentation vector< type>::vector(int) ist mentioned but I get
error messages that there is no candidate. Only vector( const vector
<type>&) and vector() are listed in the compiler output.

Do I have to upgrade or what is wrong??

Joachim


Rolf Magnus

unread,
Feb 17, 2003, 10:40:50 AM2/17/03
to
Joachim Hussong wrote:

Could you provide some code that shows the error? The following code
does compile without errors on gcc 2.95.3 and gcc3.2 here:

#include <vector>

class c{};

int main()
{
std::vector<c>(3);
}

Joachim Hussong

unread,
Feb 17, 2003, 11:46:10 AM2/17/03
to
Rolf Magnus schrieb:

> Could you provide some code that shows the error? The following code
> does compile without errors on gcc 2.95.3 and gcc3.2 here:
> #include <vector>
> class c{};
> int main()
> {
> std::vector<c>(3);
> }

grmpfff. This is working too! I thought I understood C++ but I am not
shure anymore!!

OK, it is a problem of inheritance,

My construct is

#include <vector>
class a {};
template< class M>
class b : public std::vector< M> {};
b<a> c(3);

the message of g++ is

no matching function for call to `c<a>::c (int)'
candidates are: c<a>::c(const c<a>&)
c<a>::c()

Why are the empty and the copy contructor known and the other not??

Joachim

Rolf Magnus

unread,
Feb 17, 2003, 12:00:55 PM2/17/03
to
Joachim Hussong wrote:

Because constructors are not inherited. Your derived class will only
have those constructors that you provide yourself, and if you don't
provide any, the compiler generates a default constructor and a copy
constructor for you.

0 new messages