我正在制作奥赛罗比赛。 几乎所有都编码,我需要运行该程序。 但是,有错误C2228。 我不知道为什么会出现这个错误。 在我的代码中,哪一行有问题?
这是API代码。
#include "Basic.h"
#include "Othello.h"
#include "resource.h"
LRESULT CALLBACK WndProc ( HWND , UINT , WPARAM , LPARAM ) ;
HINSTANCE g_hInst ;
LPCWSTR lpszClass = TEXT ( "First" ) ;
//Tile tile () ;
int APIENTRY WinMain ( HINSTANCE hInstance , HINSTANCE hPrevInstance
, LPSTR lpszCmdParam , int nCmdShow )
{
HWND hWnd ;
MSG Message ;
WNDCLASS WndClass ;
g_hInst = hInstance ;
WndClass.cbClsExtra = 0 ;
WndClass.cbWndExtra = 0 ;
WndClass.hbrBackground = ( HBRUSH ) GetStockObject ( WHITE_BRUSH ) ;
WndClass.hCursor = LoadCursor ( NULL , IDC_ARROW ) ;
WndClass.hIcon = LoadIcon ( NULL , IDI_APPLICATION ) ;
WndClass.hInstance = hInstance ;
WndClass.lpfnWndProc = ( WNDPROC)WndProc ;
WndClass.lpszClassName = lpszClass ;
WndClass.lpszMenuName = NULL ;
WndClass.style = CS_HREDRAW | CS_VREDRAW ;
RegisterClass ( &WndClass ) ;
hWnd = CreateWindow ( lpszClass , lpszClass , WS_OVERLAPPEDWINDOW ,
CW_USEDEFAULT , CW_USEDEFAULT , CW_USEDEFAULT , CW_USEDEFAULT ,
NULL , ( HMENU ) NULL , hInstance , NULL ) ;
ShowWindow ( hWnd , nCmdShow ) ;
while ( GetMessage ( &Message , 0 , 0 , 0 ) )
{
TranslateMessage ( &Message ) ;
DispatchMessage ( &Message ) ;
}
return Message.wParam ;
}
LRESULT CALLBACK WndProc ( HWND hWnd , UINT iMessage , WPARAM wParam , LPARAM lParam )
{
HDC hdc , hMemdc [ 3 ] ;
PAINTSTRUCT ps ;
HBITMAP hEmpty , hBlack , hGray ;
BITMAP bit ;
Tile tile () ;
switch(iMessage)
{
case WM_LBUTTONDOWN :
break ;
case WM_PAINT :
hdc = BeginPaint ( hWnd , &ps ) ;
for ( int i = 0 ; i < 3 ; ++i )
{
hMemdc [ i ] = CreateCompatibleDC ( hdc ) ;
}
hEmpty = LoadBitmap ( g_hInst , MAKEINTRESOURCE ( IDB_BITMAP1 ) ) ;
hBlack = LoadBitmap ( g_hInst , MAKEINTRESOURCE ( IDB_BITMAP2 ) ) ;
hGray = LoadBitmap ( g_hInst , MAKEINTRESOURCE ( IDB_BITMAP3 ) ) ;
SelectObject ( hMemdc [ 0 ] , hEmpty ) ;
SelectObject ( hMemdc [ 1 ] , hBlack ) ;
SelectObject ( hMemdc [ 2 ] , hGray ) ;
for ( int j = 0 ; j < 10 ; ++j )
{
for ( int i = 0 ; i < 10 ; ++i )
{
BitBlt ( hdc , 50 * i , 50 * j , 50 , 50 , hMemdc [ tile . iTileinfo ( i , j ) ] , 0 , 0 , SRCCOPY ) ;
}
}
BitBlt ( hdc , 550 , 250 , 50 , 50 , hMemdc [ 2 - ( tile . bTurninfo () ) ] , 0 , 0 , SRCCOPY ) ;
DeleteObject ( hEmpty ) ;
DeleteDC ( hMemdc [ 0 ] ) ;
DeleteObject ( hBlack ) ;
DeleteDC ( hMemdc [ 1 ] ) ;
DeleteObject ( hGray ) ;
DeleteDC ( hMemdc [ 2 ] ) ;
EndPaint ( hWnd , &ps ) ;
break ;
case WM_DESTROY :
PostQuitMessage ( 0 ) ;
return 0 ;
}
return ( DefWindowProc ( hWnd , iMessage , wParam , lParam ) ) ;
}
这是类代码。
#include "Othello.h"
Tile :: Tile ()
{
aryRemover = new Remover [ 8 ] ;
for ( int i = 0 ; i < 8 ; ++i )
{
aryRemover [ i ] . iDirection = 0 ;
aryRemover [ i ] . iNum = 0 ;
}
for ( int i = 0 ; i < 10 ; ++i )
{
for ( int j = 0 ; j < 10 ; ++j )
{
iAry [ i ] [ j ] = 0 ;
}
}
iAry [ 4 ] [ 4 ] = 1 ;
iAry [ 4 ] [ 5 ] = 2 ;
iAry [ 5 ] [ 4 ] = 2 ;
iAry [ 5 ] [ 5 ] = 1 ;
bTurn = false ;
iCount = 0 ;
}
Tile :: ~ Tile ()
{
delete [] aryRemover ;
}
void Tile :: Possible ( int iX , int iY )
{
if ( bTurn ) // Player 1
{
long code
}
else // Player 2
{
long code
}
}
void Tile :: Change ( int iX , int iY )
{
if ( bTurn ) // Player 1
{
for ( int i = 0 ; i < iCount ; ++i )
{
switch ( aryRemover [ i ] . iDirection )
{
case 0 :
long code
default :
break ;
}
}
bTurn = false ; // Turn Player 2
iCount = 0 ;
}
else // Player 2
{
for ( int i = 0 ; i < iCount ; ++i )
{
switch ( aryRemover [ i ] . iDirection )
{
case 0 :
long code
default :
break ;
}
}
bTurn = true ; // Turn Player 1
iCount = 0 ;
}
}
int Tile :: iTileinfo ( int iX , int iY )
{
return iAry [ iX ] [ iY ] ;
}
bool Tile :: bTurninfo ()
{
if ( bTurn )
return true ;
else
return false ;
}
void Tile :: Routine ( int iX , int iY )
{
Tile :: Possible ( iX , iY ) ;
Tile :: Change ( iX , iY ) ;
}
和错误。
错误C2228:'。bTurninfo'的左边必须有class / struct / union。
错误C2228:'。iTileinfo'的左边必须有class / struct / union。
问题的代码是API代码。
在WM_PAINT
部分,代码使用Bitblt
函数。
我等你的回答。 祝你有个美好的一天:)
答案 0 :(得分:2)
Tile tile () ;
声明一个函数tile()。
你想要
Tile tile;
创建一个tile对象