簡體   English   中英

錯誤1錯誤C2664:'arl :: contFolder * arl :: list :: setDown(arl :: contFolder *,int *)':無法將參數2從'unsigned int'轉換為'int *'

[英]Error 1 error C2664: 'arl::contFolder *arl::list::setDown(arl::contFolder *,int *)' : cannot convert argument 2 from 'unsigned int' to 'int *'

我有功能

void file::pg_down(fldr *f)
    {
        drawItem(*f, drw::Colours::blueVivid);
        f->item_pos = myList.setDown(f->active->next, f->cord.x);
        if (!strcmp(f->item_pos->name, myStr))
            f->item_pos = f->item_pos->prev;

        drawItem(*f, drw::Colours::greenVivid);
    }

調用函數

contFolder* list::setDown(contFolder* current, int *xCord)
    {
        arl::contFolder* tmp = NULL;
        arl::contFolder* i = NULL;
        for (i = current; i->next; i = i->next, xCord++)
        {
            if (!strcmp(i->name, myStr))
            {
                tmp = i;
                return tmp;
            }
        }
        tmp = i;
        return tmp;
    }

我需要函數contFolder * list :: setDown(contFolder * current,int * xCord)來更改xCord的值,但無法理解如何正確傳遞此參數。 因此我有錯誤

錯誤1錯誤C2664:'arl :: contFolder * arl :: list :: setDown(arl :: contFolder *,int *)':無法將參數2從'unsigned int'轉換為'int *'

你會推薦什么?

myList.setDown(f->active->next, f->cord.x);

應該

myList.setDown(f->active->next, (int*)&f->cord.x);

您的函數setDown需要一個int* ,而不是一個int ,因此傳遞變量的地址。

另外,您有一個類型不匹配。 將坐標存儲為unsigned int時,為什么函數會采用int* 只要選擇正確的類型...

contFolder* list::setDown(contFolder* current, unsigned int *xCord);

順便說一句,您實際上從未使用過xCord 您增加它,但是它是指針的副本,因此它對f->cord.x沒有影響。 您實際上想在這里做什么? 如果您嘗試增加f->cord.x則需要使用(*xCord)++

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM