[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug using vector<const pointer>
From: |
Peter Mansbach |
Subject: |
bug using vector<const pointer> |
Date: |
Fri, 22 Nov 2002 16:23:28 -0500 |
I can pass a (non-const) pointer to a function that expects a const pointer.
However, g++ will not let me pass a vector of (non-const) pointers to a
function that expects a vector of const pointers. Here's a simplified
example:
=========================
#include <vector>
class BurstMonitor;
void testfunc(vector<const BurstMonitor*>* vecc)
{
(void) vecc;
}
void func(vector<BurstMonitor *>testvec)
{
testfunc(&testvec);
BurstMonitor *objp = testvec[0];
}
=========================
Compiling this file with the command line
g++ -o testcptr.o testcptr.cpp
generates the output:
testcptr.cpp: In function `void func(vector<BurstMonitor
*,allocator<BurstMonitor *> >)':
testcptr.cpp:11: type `vector<const BurstMonitor *,allocator<const
BurstMonitor *> >' is not a base type for type `vector<BurstMonitor
*,allocator<BurstMonitor *> >'
and no object file is produced. We're using
gcc version 2.95.2 19991024 (release)
on Solaris 2.8 (SunOS vsatsun28 5.8 Generic_108528-14 sun4u sparc
SUNW,Ultra-5_10)
Thanks,
Peter Mansbach
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug using vector<const pointer>,
Peter Mansbach <=