public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* requesting help for g++/gcc v3.2 on redhat Linux8.0.
@ 2002-12-09 21:32 RAMU MEDA (HP INDIA ,Bangalore)
  2002-12-10  5:13 ` John Love-Jensen
  0 siblings, 1 reply; 2+ messages in thread
From: RAMU MEDA (HP INDIA ,Bangalore) @ 2002-12-09 21:32 UTC (permalink / raw)
  To: gcc-help


Hi ,
>
> REQUEST 1:

  requesting help for g++/gcc v3.2 on redhat Linux8.0(intel).
> The errors we got for test.cpp are listed below.
> we request for your inputs, if any ,to solve the problem.
> ( For your information, same code is working fine on g++ v2.96)
>
> REQUEST 2:

  Also , what is the option on gcc  for : "Turns on newly supported ANSI C++
Standard features
  like namespace std and the new C++ Standard Library"? please let us know.
>
> =================test.cpp========================
> #include <vector>
>
> using namespace std;
> class a
> {
> };
>
> class b : public a
> {
> };
>
> int main()
> {
>  vector<a*> v;
>  vector<b*>::iterator listiterator;
>  typedef vector<b*>::iterator biter;
>  listiterator=(biter) (v.begin());
> }
> ===========================================
> ERRORS for g++ test.cpp
> =============================================
>
> test.cpp: In function `int main()':
> test.cpp:17: no matching function for call to `
>    __gnu_cxx::__normal_iterator<b**, std::vector<b*, std::allocator<b*> >
> >::
>    __normal_iterator(__gnu_cxx::__normal_iterator<a**, std::vector<a*,
>    std::allocator<a*> > >)'
> /usr/include/c++/3.2/bits/stl_iterator.h:571: candidates are:
>    __gnu_cxx::__normal_iterator<b**, std::vector<b*, std::allocator<b*> >
>    >::__normal_iterator(const __gnu_cxx::__normal_iterator<b**,
> std::vector<b*,
>    std::allocator<b*> > >&)
> /usr/include/c++/3.2/bits/stl_iterator.h:584:
>    __gnu_cxx::__normal_iterator<_Iterator,
> _Container>::__normal_iterator(const
>    _Iterator&) [with _Iterator = b**, _Container = std::vector<b*,
>    std::allocator<b*> >]
> /usr/include/c++/3.2/bits/stl_iterator.h:581:
>    __gnu_cxx::__normal_iterator<_Iterator,
_Container>::__normal_iterator()
>    [with _Iterator = b**, _Container = std::vector<b*, std::allocator<b*>
>]
> =================================================
>

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: requesting help for g++/gcc v3.2 on redhat Linux8.0.
  2002-12-09 21:32 requesting help for g++/gcc v3.2 on redhat Linux8.0 RAMU MEDA (HP INDIA ,Bangalore)
@ 2002-12-10  5:13 ` John Love-Jensen
  0 siblings, 0 replies; 2+ messages in thread
From: John Love-Jensen @ 2002-12-10  5:13 UTC (permalink / raw)
  To: mramu, gcc-help

Hi Ramu,

>#1 requesting help for g++/gcc v3.2 on redhat Linux8.0(intel).

A vector<a*>::iterator is not compatible with a vector<b*>::iterator.  There
are no casts to convert these UDTs from one to the other.

It fails the same way that this fails:
void foo(auto_ptr<a> value);
int main() {
  auto_ptr<b> ptr(new b);
  foo(ptr);
}

What should be done in my example is:
int main() {
  auto_ptr<a> ptr(new b);
  foo(ptr);
}

What you need in your example is:
int main() {
  vector<a*> v; // Really contains b* pointers (?).
  vector<a*>::iterator listiterator;
  listiterator = v.begin();
  a* aptr = *listiterator;
  b& bobj = dynamic_cast<b&>(*a);
}

>#2 Also, what is the option on gcc for: "Turns on newly supported ANSI C++
Standard features like namespace std and the new C++ Standard Library"?

They are on by default with GCC 3.2.

--Eljay

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-12-10 13:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-09 21:32 requesting help for g++/gcc v3.2 on redhat Linux8.0 RAMU MEDA (HP INDIA ,Bangalore)
2002-12-10  5:13 ` John Love-Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).