新手提问:请教几个问题?
amiao 2004-11-24 03:25:46 1. 在头文件中定义了一个字符串,const char* str = "hello, world";
编译程序OK,但链接程序报错
‘error LNK2005: "char const * const str" (?str@@3PBDB) already defined in apicommDlg.obj’
而为什么 const char str[] = "hello, world"; 却正确
2. ::AfxMessageBox("hello,world"); 中的‘::’是什么意思?不加此符号和加上符号有什么区别?
3. VC中有没有类似Delphi中这样的功能:
xxx.pas文件中启动初始化类
var
hs : OCommon;
initialization
hs.Create;
finalization
hs.Destroy;
4. unsigned 是 32 位的无符号数据类型,那么 unsigned char c; 中的 c 是几位?占用几个字节空间?
5. C++ 中的各种指针占用内存空间是否一样,几个字节? char* p1 和 int* p2,p1 和 p2 在栈上是否都
占用 4 个字节空间?
6. 怎样获得当前执行文件的路径名称?类似Delphi中的ExtractFilePath(Application.ExeName);
7. 宏定义(#define)和常量定义(const)到底有什么区别?他们怎样存储?
定义了 #define HELLO "hello,world" 这样一个宏,怎样使用?
8. VC中有没有类似Delphi中的 Application.ProcessMessages; 同步应用程序函数
9. 在上面的函数内,有如下代码:
CApicommDlg &p=*(CApicommDlg *)pParam;
p.UpdateData(TRUE); // 编译链接正确,运行出错
p.m_strReceive = "hello,world"; // 编译链接运行正确
为什么 p.UpdateData(TRUE) 会报错,而调用其他的变量正确?