⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_36728.htm

📁 一些关于vc的问答
💻 HTM
字号:
<p>
序号:36728 发表者:xujin 发表日期:2003-04-18 02:03:38
<br>主题:初学者之不解(一)
<br>内容:  最近看了些例子和程序,发现有些函数定义的尾部加上CONST,不知有何意义????<BR>  还有谁能告诉我VC做什么方面的编程比较好?
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:neilgan 回复日期:2003-04-18 07:01:28
<br>内容:It means that this member function never write any member variables.
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:xujin 回复日期:2003-04-18 08:34:22
<br>内容:是说函数里面只能使用接受的变量,不充许再定义和使用其他变量吗?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:neilgan 回复日期:2003-04-18 09:24:06
<br>内容:class CAnyClass<BR>{<BR>private:<BR>&nbsp;&nbsp;&nbsp;&nbsp;int mnMemberVariable;<BR>&nbsp;&nbsp;&nbsp;&nbsp;void AnyFunc(void)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp; ...<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;void ConstFunc(void) const<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AnyFunc(); //error, cann't call non-const member function<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mnMemberVariable=3; //error, cann't write member variable<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int i=mnMemberVariable; //ok<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AnotherConstFunc(); //ok<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;void AnotherConstFunc(void) const<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;...<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>};
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:xujin 回复日期:2003-04-18 09:57:43
<br>内容:谢谢。能看看下段程序问题吗(二个问题)?<BR>pragma comment(linker,"/subsystem:windows")<BR>#pragma comment(linker,"/entry:WinMainCRTStartup")<BR><BR>#include "basetsd.h"<BR>#include "C:\Program Files\Microsoft Visual Studio\VC98\Include\Windows.h" <BR>LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM); <BR>int WINAPI WinMain(HINSTANCE hInstance, <BR>HINSTANCE hPrevInst,LPSTR lpszCmdLine,int nCmdShow) <BR>{ <BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>HWND hwnd ; <BR>MSG Msg ; <BR>WNDCLASSA wndclass ; <BR>char lpszClassName[] = "窗口"; <BR>char lpszTitle[]= "My_Windows"; <BR>wndclass.style=0; //样式若改成WS_HSCROLL|WS_VSCROLL|WS_WS_OVERLAPPEDWINOW窗口会无法显示。<BR>wndclass.lpfnWndProc=WndProc; <BR>wndclass.cbClsExtra=0; <BR>wndclass.cbWndExtra=0; <BR>wndclass.hInstance=hInstance; <BR>wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);<BR>wndclass.hCursor=LoadCursor(NULL,IDC_ARROW) ;<BR>wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);<BR>wndclass.lpszMenuName=NULL; <BR>wndclass.lpszClassName=lpszClassName ;<BR>if(!RegisterClass( &amp;wndclass))<BR>{ MessageBeep(0) ; return FALSE ; } ;<BR>hwnd=CreateWindow(lpszClassName,lpszTitle,WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,<BR>CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT,NULL, NULL, hInstance, NULL );<BR>ShowWindow( hwnd, nCmdShow) ;<BR>UpdateWindow(hwnd);<BR>while( GetMessage(&amp;Msg, hwnd, 0, 0))<BR>{<BR>TranslateMessage( &amp;Msg) ;<BR>DispatchMessage( &amp;Msg) ;<BR>}<BR>return Msg.wParam; <BR>}<BR>LRESULT CALLBACK WndProc<BR>( HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)<BR>{ <BR>&nbsp;&nbsp;&nbsp;&nbsp;switch(message)<BR>{ case WM_DESTROY:<BR>PostQuitMessage(0);//退出时,关闭了窗口,但仍是在消息循环中,未能结束程序,能不能关闭窗口时,退出循环,执行return Msg.wParam;<BR>default: return DefWindowProc(hwnd,message,wParam,lParam);<BR>}<BR>return(0);<BR>}<BR> 
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:xujin 回复日期:2003-04-18 15:59:27
<br>内容:怎么没人回答啊?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:xujin 回复日期:2003-04-18 19:59:53
<br>内容:不好意思,问的太低级了,还是自己搞定了,原来是这么简单的事。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -