Problem passing a vector array as a parameter

First: I am doing maintenance on legacy code. This used to work (and still does) in a different code base.
I have a method in a class defined as : getAllArrayPtrs(vector<someObject*> &apList); Essentially, I am calling the function with a reference to the vector.
I call it where I have defined:
vector<someObject*> apl;
It is called by
pIndexed->getAllArrayPtrs(apl)
Visual Studio 2008 errors:
1>.\VariableDlg.cpp(452) : error C2664: 'hCattrVarIndex::getAllArrayPtrs' : cannot convert parameter 1 from 'std::vector<_Ty>' to 'std::vector<_Ty> &'
1> with
1> [
1> _Ty=hCitemArray *
1> ]
1> and
1> [
1> _Ty=ptr2hCitemBase_t
1> ]
Does anybody have any idea what it could be complaining about?

Thanks
The someObject thing you describe is not the same type in both cases.
I screwed up in the copying of my functions:
definition: getAllArrayPtrs(vector<someObject*> &apList);
vector is declared as vector<someObject*> ArrayPtrList;
The function was originally called as
pIndexed->getAllArrayPtrs(ArrayPtrList)
and I got
1>.\VariableDlg.cpp(452) : error C2664: 'hCattrVarIndex::getAllArrayPtrs' : cannot convert parameter 1 from 'std::vector<_Ty>' to 'std::vector<_Ty> &'
1> with
1> [
1> _Ty=hCitemArray *
1> ]
1> and
1> [
1> _Ty=ptr2hCitemBase_t
1> ]
so I declared a reference pointer
vector<someObject*> &apl = ArrayPtrList;
and get the same thing with
pIndexed->getAllArrayPtrs(apl)

I misstated the problem. Sorry.

Can you post the actual code with actual. The compiler says you've not specified the same types to vector in both cases.
Method declaration:
RETURNCODE getAllArrayPtrs(vector<hCitemBase*> &ArrayPtrList);// for all conditional outcomes
vector declaration:
vector<hCitemArray*> ArrayPtrList;
vector<hCitemArray*> &apl = ArrayPtrList;
vector<hCitemArray*> ::iterator aplIT;// ptr 2a ptr 2a hCitemArray

I added the apl reference pointer later. The original code just used ArrayPtrList as the parameter.

The actual function call:

if ( ((hCindex *)(m_pVar->m_pddbVar))->pIndexed != NULL )
{
if ( ((hCindex *)(m_pVar->m_pddbVar))->pIndexed->getAllArrayPtrs(apl) == SUCCESS && ArrayPtrList.size() > 0)
{// for all conditional outcomes
for (aplIT = ArrayPtrList.begin();aplIT < ArrayPtrList.end(); aplIT++)
{

It was originally getAllArrayPtrs(ArrayPtrList).

Thanks.

vector<hCitemBase*> is not the same as vector<hCitemArray*>. You can't pass a reference or pointer of one to a function expecting the other.

As I said to beginning, the someObject thing you describe is not the same type in both cases.

Is hCitemBase a base class of hCitemArray? If so, you need to traverse the vector and pass each element, one at a time. And you must have a function that accepts hCitemBase* as a parameter.
Last edited on
Bingo! That evidently changed and I didn't notice it when I merged the code. Thank you very much! I needed another set of eyes. I looked at that over and over and I think my brain did an autocorrect or something. Thanks again.
Topic archived. No new replies allowed.