错误C2228使用API
Error C2228 using API
我正在制作奥赛罗游戏。几乎所有的代码,我需要运行程序。但是,错误是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: left of '。bTurninfo'必须有class/struct/union。
错误C2228: left of '。iTileinfo'必须有class/struct/union。
问题代码在API代码中
在WM_PAINT
段,代码使用Bitblt
函数。
我等你的回答。祝你过得愉快!
Tile tile () ;
声明一个函数tile()。
你想要的Tile tile;
创建一个tile对象
相关文章:
- 如何使用Luacneneneba API正确读取字符串和表参数
- 如何使用 AWS Transcribe C++ API 中的'StartTranscriptionJobRequest'?
- 在gtest.中使用fff.h模拟系统API
- 使用libcurl提交批量url的正确BING Api POST url是什么
- 使用Qt框架在c ++类中创建API调用
- 使用 WIN32 API (C/C++) 对特定树视图项进行着色
- Python C API:使用 MSVC 尝试示例模块时的访问冲突
- 取消API使用的调用
- Fetch API 使用 Electron 使用非 HTTP-Scheme,但不使用 CEF
- 构造函数中发生异常时如何释放 API 使用的资源
- 使用C API使用GSL :: ZSTRING_VIEW
- Numpy C API - 使用 PyArray_Descr 创建数组会导致段错误
- 使用C 中的Windows API使用多线程列出文件
- C++库API.使用转换器类而不是普通的C api
- Microsoft HTTP 服务器 API - 使用 SSL,如何要求客户端证书
- 使用加密API使用ECDH签名:下一代C++
- 为API使用std::函数(跨越模块边界)
- facebook图形API使用libcurl/其他库
- Python C API使用WinPython Python解释器而不是标准Python解释器
- 谷歌云语音API使用C++,第一步是什么