problems using vector in gcc3.2 on Redhat linux8.0

RAMU MEDA (HP INDIA ,Bangalore) mramu@india.hp.com
Tue Dec 10 02:25:00 GMT 2002


Hi,

I am also having the same problem using vector in gcc3.2 on Redhat linux8.0.

I want to type cast parent vector class iterator to child vector class
iterator...
(The piece of code works without any warnings or errors on gcc v2.96 on
redaht linux)
Can You please suggest some solution.

piece of code:

===================test.cpp====================
#include <vector>
using namespace std;

class a
{
};

class b : public a
{
};

int main()
{

vector<b*>::iterator ListIterator;
vector<a*> a;

ListIterator=(b**)(a.begin());

}
==============================================
Errors for g++ test.cpp
================================================
test.cpp: In function `int main()':
test.cpp:18: cannot convert `std::vector<_Tp, _Alloc>::begin() [with _Tp =
a*,
   _Alloc = std::allocator<a*>]()' from type
`__gnu_cxx::__normal_iterator<a**,
   std::vector<a*, std::allocator<a*> > >' to type `b**'
================================================


Regards,
Ramu Meda
29, Hewlett Packard ISO
Cunningham Road, Bangalore
Phone (o): (91) (80)  2051181 (Direct)
Email (p) : ramumeda@yahoo.com




More information about the Gcc-help mailing list