Visual C ++无法正确填写构造函数要求

时间:2013-05-10 20:02:01

标签: c++ visual-c++ constructor

所以我似乎无法正确填写此构造函数的要求。

DIVA_STATUS DIVA_getObjectDetailsList (
IN BOOL                   pFirstTime,
IN time_t                 *initialTime,
IN int                    pListType,
IN int                    pObjectsListType,
IN int                    pMaxListSize,
IN DIVA_STRING            pObjectName,
IN DIVA_STRING            pObjectCategory
IN DIVA_STRING            pMediaName
DIVA_LEVEL_OF_DETAIL      pLevelOfDetail,
IN vector<DIVA_STRING>    listPosition,
OUT vector<DIVA_OBJECT_DETAILS_LIST>      *&pObjectDetailsList
)

问题似乎是输出类向量的最后一行(???)。我对C ++有点生疏,所以我不记得为什么你会取消引用参考调用(*&amp;)。

DIVA_OBJECT_DETAILS_LIST是一个如下所示的类:

class DIVA_OBJECT_DETAILS_LIST {
public:
int                            listType;
DIVA_STRING                    siteID;
vector<DIVA_STRING>            *listPosition;
vector<DIVA_OBJECT_INFO>       *objectInfo;
vector<DIVA_OBJECT_TAPE_INFO>  *objectTapeInfo;
};

以下是我尝试使用VC ++ 2008 Express进行编译时得到的结果

1>Compiling...
1>initiator.cpp
1>.\initiator.cpp(148) : error C2100: illegal indirection
1>.\initiator.cpp(148) : error C2665: 'DIVA_getObjectDetailsList' : none of the 2 overloads could convert all the argument types
1>        z:\Mediavault1\Automation\DIVA_API\DIVArchiveAPI\CppAPI Test\include\DIVAapi.h(2191): could be 'DIVA_STATUS DIVA_getObjectDetailsList(bool,time_t,int,int,int,DIVA_STRING,DIVA_STRING,DIVA_STRING,DIVA_LEVEL_OF_DETAIL,std::vector<_Ty>,DIVA_OBJECT_DETAILS_LIST *&)'
1>        with
1>        [
1>            _Ty=DIVA_STRING
1>        ]
1>        while trying to match the argument list '(bool, time_t, int, int, int, DIVA_STRING, DIVA_STRING, DIVA_STRING, DIVA_LEVEL_OF_DETAIL, std::vector<_Ty>, DIVA_OBJECT_DETAILS_LIST *)'
1>        with
1>        [
1>            _Ty=DIVA_STRING
1>        ]

以下是我调用构造函数的方法:

cr = DIVA_getObjectDetailsList (
                   _firstTime,
                   (time_t)_initDate,
                   (int)DIVA_OBJECTS_LIST,
                   (int)DIVA_OBJECTS_CREATED_SINCE,
                   _size,
                   _name,
                   _category,
                   _group,
                   DIVA_INSTANCE,
                   *_listType.listPosition,
                   &*_listType
                   );

_listType是DIVA_OBJECT_DETAILS_LIST。如何通过引用传递指针?

1 个答案:

答案 0 :(得分:2)

问题似乎是倒数第二个参数。当您传递std::vector<DIVA_STRING>*(而不是指针)时,您传递的是std::vector<DIVA_STRING>

但为了帮助您理解最后一个参数,vector<DIVA_OBJECT_DETAILS_LIST>*&是“指向vector<DIVA_OBJECT_DETAILS_LIST>”类型的指针。也就是说,你应该传递一个指针,然后通过引用传递它。