const wchar_t *和wchar_t const *的问题

muwanqing 2010-03-12 04:45:46
const wchar_t *和wchar_t const * 区别是什么

如何把wchar_t const * 转换成 const wchar_t *
...全文
763 16 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
rome55 2010-03-12
  • 打赏
  • 举报
回复
其实有区别的,
我觉得 const wchar 的效率要比wchar高一点点
lovesi3344 2010-03-12
  • 打赏
  • 举报
回复

星号左边的const和wchar_t的位置无关紧要
xboy 2010-03-12
  • 打赏
  • 举报
回复
wchar_t const * 和 const wchar_t *是没有区别的
muwanqing 2010-03-12
  • 打赏
  • 举报
回复
多谢大家
gueangyik 2010-03-12
  • 打赏
  • 举报
回复
const wchar_t * 指向const wchar类型的 指针
wchar_t const * 同上
wchar_t * const const指针 指针本身是const 他不能指向别的对象
白云飘飘飘 2010-03-12
  • 打赏
  • 举报
回复
const wchar_t *和wchar_t const *没有区别,都是指向常量的指针,如果是这样wchar_t *const则变成了常指针。
RubishHunter 2010-03-12
  • 打赏
  • 举报
回复
区分的关键在于指针和星号的相对位置!
Julykey 2010-03-12
  • 打赏
  • 举报
回复
没区别,是通过const左边和右边的类型来区别的。这里是一样的
muwanqing 2010-03-12
  • 打赏
  • 举报
回复
const wchar_t *是函数的一个参数 参数调用错误 会导致连接错误

那既然没区别 就不是这个问题

具体看另一个帖子
http://topic.csdn.net/u/20100312/00/e032f3df-a752-430a-b06c-4cd72fa795dc.html
ztenv 版主 2010-03-12
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 stardust20 的回复:]
引用 4 楼 lianshaohua 的回复:
const wchar_t *:是一个指向常量wchar_t类型的指针,
wchar_t const * :是一个指向wchar_t的指针,这个指针是一个常量;

希望我没有理解错;

wchar_t * const:才是一个指向wchar_t的指针,这个指针是一个常量;
这个一般是以const在'*'的左边或者右边来区分
[/Quote]

受教了。。谢谢!
wind_breez 2010-03-12
  • 打赏
  • 举报
回复
没区别!
stardust20 2010-03-12
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 lianshaohua 的回复:]
const wchar_t *:是一个指向常量wchar_t类型的指针,
wchar_t const * :是一个指向wchar_t的指针,这个指针是一个常量;

希望我没有理解错;
[/Quote]
wchar_t * const:才是一个指向wchar_t的指针,这个指针是一个常量;
这个一般是以const在'*'的左边或者右边来区分
ztenv 版主 2010-03-12
  • 打赏
  • 举报
回复
const wchar_t *:是一个指向常量wchar_t类型的指针,
wchar_t const * :是一个指向wchar_t的指针,这个指针是一个常量;

希望我没有理解错;
昵称很不好取 2010-03-12
  • 打赏
  • 举报
回复
这两个是一样的
stardust20 2010-03-12
  • 打赏
  • 举报
回复
同一楼。。const wchar_t *和wchar_t const * 两个是一样的
tan870426 2010-03-12
  • 打赏
  • 举报
回复
两个完全一样的~!
跟wchar_t *const有区别!
// // FilePath.h // /** \file FilePath.h */ #pragma once #include "vtString.h" #include #include /** * A portable class for reading directory contents. * * Example of use: \code for (dir_iter it("C:/temp"); it != dir_iter(); ++it) { if (it.is_hidden()) continue; if (it.is_directory()) printf("Directory: '%s'\n", it.filename().c_str()); else printf("File: '%s'\n", it.filename().c_str()); } \endcode */ class dir_iter { public: dir_iter(); dir_iter(const char*dirname); dir_iter(const wchar_t*dirname); ~dir_iter(); /// Returns true if the current object is a directory. bool is_directory(); /// Returns true if the current object is hidden. bool is_hidden(); /// Get the filename fo the current object. std::string filename(); std::wstring wfilename(); // Iterate the object to the next file/directory. void operator++(); // Test for inequality useful to test when iteration is finished. bool operator!=(const dir_iter ⁢); long m_handle; private: struct _wfinddata_t m_data; }; //MBCS string 或者 Wide string vtString vtFindFileOnPaths(const vtStringArray &paths;, const char *filename); vtString2 vtFindFileOnPaths(const vtStringArray2 &paths;, const wchar_t *filename); bool vtCreateDir(const char *dirname); bool vtCreateDir(const wchar_t *dirname); void vtDestroyDir(const char *dirname); void vtDestroyDir(const wchar_t *dirname); int vtDeleteFile(const char *filename); int vtDeleteFile(const wchar_t *filename); const char *vtStartOfFileName(const char *szFullPath); const wchar_t *vtStartOfFileName(const wchar_t *szFullPath); vtString vtExtractPath(const char *szFullPath, bool bTrailingSlash); vtString2 vtExtractPath(const wchar_t *szFullPath, bool bTrailingSlash); bool vtPathIsAbsolute(const char *szPath); bool vtPathIsAbsolute(const wchar_t *szPath); vtString vtPathLevelUp(const char *src); vtString2 vtPathLevelUp(const wchar_t *src); vtString get_line_from_stream(std::ifstream &input;); vtString2 get_line_from_stream(std::wifstream &input;); //bFull为ture包括所有扩展名;否则最后一个扩展名 void vtRemoveFileExtensions(vtString& fname,bool bFull = false); void vtRemoveFileExtensions(vtString2& fname,bool bFull = false); //bFull为ture包括所有扩展名;否则最后一个扩展名 vtString vtGetExtensions(const vtString &fname;, bool bFull = false); vtString2 vtGetExtensions(const vtString2 &fname;, bool bFull = false); bool vtChangeFileExtension(vtString& input, const char *extension); bool vtChangeFileExtension(vtString2& input, const wchar_t *extension); bool vtFileExists(const char *fname); bool vtFileExists(const wchar_t *fname); #pragma comment(lib, "shell32.lib") bool vtCopyFile( const char* from,const char * to, bool bFailIfExists=true); bool vtCopyFile( const wchar_t* from,const wchar_t * to, bool bFailIfExists=true); bool vtCopyTree(const char* from,const char * to); bool vtCopyTree(const wchar_t* from,const wchar_t * to); bool vtFolderExists(const char *fname); bool vtFolderExists(const wchar_t *fname); bool vtFilePathExists(const char *fname); bool vtFilePathExists(const wchar_t *fname); int vtGetFileSize(const char *fname); int vtGetFileSize(const wchar_t *fname); void vtSetEnvironmentVar(const char* var, const char*value); void vtSetEnvironmentVar(const wchar_t* var, const wchar_t*value); #include "windows.h" bool vtGetModuleFullPath(const char* modulename,vtString& fullpath); bool vtGetModuleFullPath(const wchar_t* modulename,vtString2& fullpath); ///////////////////////////////////////////// // Open a file using a UTF-8 or wide character filename. FILE *vtFileOpen(const char *fname_mbcs, const char *mode); FILE *vtFileOpen(const wchar_t *fname_wide, const wchar_t *mode); vtString vtChooseFolder(HWND hWnd =NULL); vtString2 vtChooseFolder2(HWND hWnd=NULL);

65,187

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧