【掲示板ご利用上の注意】

 ※題名は具体的に!
 ※学校の課題の丸投げ禁止!
 ※ソースの添付は「HTML変換ツール」で字下げ!
 ※返信の引用は最小限に!
 ※環境(OSとコンパイラ)や症状は具体的に詳しく!
 ※マルチポスト(多重投稿)は謹んで!

 詳しくはこちら



 本当はこんなに大きく書きたくはないのですが、なかなか守っていただけなくて…。
 守ってくださいね。お願いします。(by管理人)

C言語ソース⇒HTML形式ツール   掲示板2こちら


管理者用メニュー    ツリーに戻る    携帯用URL    ホームページ    ログ    タグ一覧

No.18923

クラスのメンバー関数のオーバーロードのエラー
投稿者---シン(2004/12/30 01:04:10)


クラス内部で関数のオーバーロードをしようと思った矢先、エラーが発生してしまい、かつ原因が究明できていません。オーバーロードに関しては、何度か使用しているのでコード的には問題がないと思うのですが・・・^^;
エラーコードとソースコードを提示させていただきますので、何がお気づきの点がありましたら教えてください。
開発環境
VisualStdio.net 2003
WindowsXP

エラーコード
error C2086: 'INT cy' : 再定義されました。
エラー対象の行は、ClassGraphicEngine.cppの
VOID ClassGraphicEngine::DC_Rectangle(INT x,INT y,INT cy,INT cy,COLORREF color)
の部分です。




この投稿にコメントする

削除パスワード

発言に関する情報 題名 投稿番号 投稿者名 投稿日時
<子記事> Re:クラスのメンバー関数のオーバーロードのエラー 18924 シン 2004/12/30 01:06:27
<子記事> Re:クラスのメンバー関数のオーバーロードのエラー 18925 シン 2004/12/30 01:10:55
<子記事> Re:クラスのメンバー関数のオーバーロードのエラー 18926 シン 2004/12/30 01:16:12


No.18924

Re:クラスのメンバー関数のオーバーロードのエラー
投稿者---シン(2004/12/30 01:06:27)


ソースコード
****** ClassGraphicEngine.h *****************************
/**************************************************************************************************
    Structure
**************************************************************************************************/
/*=================================================================================================
    RGB
=================================================================================================*/
typedef struct tagCOLOR_RGB{
    BYTE                            bRed;
    BYTE                            bGreen;
    BYTE                            bBlue;
}COLOR_RGB,*LPCOLOR_RGB;
/**************************************************************************************************
    Const parameter
**************************************************************************************************/
//=== Heap size ===================================================================================

#define GRAPHIC_HEAP_SIZE         65536
//=== Default bit count ===========================================================================

#define DEFAULT_BIT_COUNT         24
/**************************************************************************************************
    class declaration
**************************************************************************************************/
class ClassGraphicEngine{
    //=== constructor =============================================================================

    public:
        ClassGraphicEngine(HWND,INT,INT);
    //=== destructor ==============================================================================

    public:
        ~ClassGraphicEngine(void);

    //=== Variable ================================================================================

    private:
        HANDLE                      hHeap;
        HBITMAP                     hBitmap;
        HWND                        hTargetWnd;
        SIZE                        size;
        UINT                        uiBitLength;
        LPBITMAPINFO                lpBitmapInfo;
        LPRGBQUAD                   lpRgbQuad;
        LPBYTE                      lpBit;

    //=== Change state ============================================================================

    public:
        //--- Change size -------------------------------------------------------------------------

        VOID                        ChangeSize(INT,INT);

    //=== Update ==================================================================================

    public:
        //--- Transfer bit block ------------------------------------------------------------------

        VOID                        BitMove(HDC,INT,INT,INT,INT);

    //=== Draw control ============================================================================

    public:
        //--- Rectangle ---------------------------------------------------------------------------

        VOID                        DC_Rectangle(INT,INT,INT,INT,COLORREF,DWORD);
        VOID                        DC_Rectangle(INT,INT,INT,INT,COLORREF);
};
/**************************************************************************************************
    File end
**************************************************************************************************/





この投稿にコメントする

削除パスワード

No.18925

Re:クラスのメンバー関数のオーバーロードのエラー
投稿者---シン(2004/12/30 01:10:55)


定義の部分は長いので複数に分けさせていただきますm(__)m
コードは結構見やすく書いたつもりなのであまり問題はないと思うのですが^^;

/**************************************************************************************************
    class definition
**************************************************************************************************/
/*=================================================================================================
    constructor
=================================================================================================*/
ClassGraphicEngine::ClassGraphicEngine(HWND hWnd,INT cx,INT cy)
{
    this->hTargetWnd = hWnd;
    this->size.cx = cx;
    this->size.cy = cy;
    this->uiBitLength = size.cx * 3 + (4 - (size.cx * 3) % 4);

    //--- Create heap -----------------------------------------------------------------------------

    this->hHeap = HeapCreate(HEAP_GENERATE_EXCEPTIONS,HEAP_INIT_SIZE,0);

    //--- Get device context ----------------------------------------------------------------------

    HDC        hDC = GetDC(hWnd);

    //--- Allocate heap ---------------------------------------------------------------------------

    DWORD                     dwSize = sizeof(BITMAPINFO);
    this->lpBitmapInfo = (LPBITMAPINFO)HeapAlloc(this->hHeap,HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY,dwSize);

    //--- Create DIB ------------------------------------------------------------------------------

    this->lpBitmapInfo->bmiHeader.biSize            = sizeof(BITMAPINFOHEADER);
    this->lpBitmapInfo->bmiHeader.biWidth           = cx;
    this->lpBitmapInfo->bmiHeader.biHeight          = cy;
    this->lpBitmapInfo->bmiHeader.biPlanes          = 1;
    this->lpBitmapInfo->bmiHeader.biBitCount        = DEFAULT_BIT_COUNT;
    this->lpBitmapInfo->bmiHeader.biCompression     = BI_RGB;
    this->lpBitmapInfo->bmiHeader.biSizeImage       = 0;
    this->lpBitmapInfo->bmiHeader.biXPelsPerMeter   = 0;
    this->lpBitmapInfo->bmiHeader.biYPelsPerMeter   = 0;
    this->lpBitmapInfo->bmiHeader.biClrUsed         = 0;
    this->lpBitmapInfo->bmiHeader.biClrImportant    = 0;

    this->hBitmap = CreateDIBSection(hDC,this->lpBitmapInfo,DIB_RGB_COLORS,(LPVOID *)(&this->lpBit),NULL,0);
    if (hBitmap == NULL){
        DebugMessage("It failed in the initialization of the graphic engine.");
    }

    ReleaseDC(hWnd,hDC);

}
/*=================================================================================================
    denstructor
=================================================================================================*/
ClassGraphicEngine::~ClassGraphicEngine(void)
{
    if (hBitmap)DeleteObject(this->hBitmap);

    HeapDestroy(this->hHeap);
}



この投稿にコメントする

削除パスワード

No.18926

Re:クラスのメンバー関数のオーバーロードのエラー
投稿者---シン(2004/12/30 01:16:12)


すみませんかき忘れです。
さっきの定義のところからGraphicEngine.cppになります。
ちなみにちゃんと#includeしています^^;

/*=================================================================================================
    Change state
=================================================================================================*/
/*-------------------------------------------------------------------------------------------------
    Change size
-------------------------------------------------------------------------------------------------*/
VOID ClassGraphicEngine::ChangeSize(INT cx,INT cy)
{
    if (hBitmap)DeleteObject(this->hBitmap);

    this->size.cx = cx;
    this->size.cy = cy;
    this->uiBitLength = size.cx * 3 + (4 - (size.cx * 3) % 4);

    //--- Get device context ----------------------------------------------------------------------

    HDC        hDC = GetDC(this->hTargetWnd);

    //--- Create DIB ------------------------------------------------------------------------------

    this->lpBitmapInfo->bmiHeader.biSize            = sizeof(BITMAPINFOHEADER);
    this->lpBitmapInfo->bmiHeader.biWidth           = cx;
    this->lpBitmapInfo->bmiHeader.biHeight          = cy;
    this->lpBitmapInfo->bmiHeader.biPlanes          = 1;
    this->lpBitmapInfo->bmiHeader.biBitCount        = DEFAULT_BIT_COUNT;
    this->lpBitmapInfo->bmiHeader.biCompression     = BI_RGB;
    this->lpBitmapInfo->bmiHeader.biSizeImage       = 0;
    this->lpBitmapInfo->bmiHeader.biXPelsPerMeter   = 0;
    this->lpBitmapInfo->bmiHeader.biYPelsPerMeter   = 0;
    this->lpBitmapInfo->bmiHeader.biClrUsed         = 0;
    this->lpBitmapInfo->bmiHeader.biClrImportant    = 0;

    this->hBitmap = CreateDIBSection(hDC,this->lpBitmapInfo,DIB_RGB_COLORS,(LPVOID *)(&this->lpBit),NULL,0);
    if (hBitmap == NULL){
        DebugMessage("It failed in the initialization of the graphic engine.");
    }

    ReleaseDC(this->hTargetWnd,hDC);

}
/*=================================================================================================
    Update
=================================================================================================*/
/*-------------------------------------------------------------------------------------------------
    Transfer bit block
-------------------------------------------------------------------------------------------------*/
VOID ClassGraphicEngine::BitMove(HDC hDC,INT x,INT y,INT cx,INT cy)
{
    if (hBitmap == NULL)return;
    HDC        hMemDC = CreateCompatibleDC(hDC);
    SelectObject(hMemDC,this->hBitmap);

    StretchBlt(hDC,x,y,cx,cy,hMemDC,0,0,this->size.cx,this->size.cy,SRCCOPY);
    DeleteDC(hMemDC);
}
/*=================================================================================================
    Update
=================================================================================================*/
/*-------------------------------------------------------------------------------------------------
    Rectangle
-------------------------------------------------------------------------------------------------*/
VOID ClassGraphicEngine::DC_Rectangle(INT x,INT y,INT cx,INT cy,COLORREF color,DWORD uiAlfaPoint)
{
    if (hBitmap == NULL)return;
    POINT                     DrawPos;
    DrawPos.x = x;
    DrawPos.y = this->size.cy - y - cy;

    //--- Get color -------------------------------------------------------------------------------

    COLOR_RGB                  Rgb;
    Rgb.bRed    = GetRValue(color);
    Rgb.bGreen  = GetGValue(color);
    Rgb.bBlue   = GetBValue(color);

    INT        i,j;
    for(j = DrawPos.y;j < DrawPos.y + cy;j++){
        for(i = DrawPos.x;i < DrawPos.x + cx;i++){
            *(this->lpBit + (this->uiBitLength * j) + (i * 3) + 0) = Rgb.bBlue;
            *(this->lpBit + (this->uiBitLength * j) + (i * 3) + 1) = Rgb.bGreen;
            *(this->lpBit + (this->uiBitLength * j) + (i * 3) + 2) = Rgb.bRed;
        }
    }
    return;
}
VOID ClassGraphicEngine::DC_Rectangle(INT x,INT y,INT cy,INT cy,COLORREF color)
{
}
/**************************************************************************************************
    File end
**************************************************************************************************/





この投稿にコメントする

削除パスワード

No.18927

Re:クラスのメンバー関数のオーバーロードのエラー
投稿者---Ban(2004/12/30 03:49:44)


エラーメッセージの通りです。

cy が引数に二つある(cx はない)と言われてるだけで、
オーバーロードの問題ではありません。


この投稿にコメントする

削除パスワード

No.18928

Re:クラスのメンバー関数のオーバーロードのエラー
投稿者---シン(2004/12/30 14:28:01)


ぎゃー(>_<)
本当だ(笑)
何度も見たのに全然気づきませんでした^^;
直したら動きました。
どうもありがとうございました。


この投稿にコメントする

削除パスワード

管理者用メニュー    ツリーに戻る    携帯用URL    ホームページ    ログ    タグ一覧