c++;使用方法const的遗留代码,仍然需要创建接受const方法成员的函数 我有传统C++代码,const方法: Id LegacyCode::GetIdByName(const char* sName, const char* pName) const { long lID; char szProcessName[MAXPATH]; for (int iP = 0; iP < iNum; iP++) { if (strnicmp(sName, "Test.exe", MAX_LENGTH) == 0) { if (strnicmp(szProcessName, pName, MAX_LENGTH) == 0) { // If the proces name was found, return its ID. return (lID); } } else if (strnicmp(sName, "Test2.exe", MAX_LENGTH) == 0) { if (strnicmp(szProcessName, pName, MAX_LENGTH) == 0) { // If the proces name was found, return its ID. return (lID); } } else { if (strnicmp(sName, szProcessName, MAX_LENGTH) == 0) return (lID); } } return (0); }

c++;使用方法const的遗留代码,仍然需要创建接受const方法成员的函数 我有传统C++代码,const方法: Id LegacyCode::GetIdByName(const char* sName, const char* pName) const { long lID; char szProcessName[MAXPATH]; for (int iP = 0; iP < iNum; iP++) { if (strnicmp(sName, "Test.exe", MAX_LENGTH) == 0) { if (strnicmp(szProcessName, pName, MAX_LENGTH) == 0) { // If the proces name was found, return its ID. return (lID); } } else if (strnicmp(sName, "Test2.exe", MAX_LENGTH) == 0) { if (strnicmp(szProcessName, pName, MAX_LENGTH) == 0) { // If the proces name was found, return its ID. return (lID); } } else { if (strnicmp(sName, szProcessName, MAX_LENGTH) == 0) return (lID); } } return (0); },c++,function,constants,C++,Function,Constants,有没有办法在不向函数membres添加可变项的情况下克服这一问题?MakeLegacyCode::isProcessNameconst: bool LegacyCode::isProcessName(char* _sName,char* _pName,char* _szProcessName) const; MakeLegacyCode::isProcessNameconst: bool LegacyCode::isProcessName(char* _sName,char* _pName,c

有没有办法在不向函数membres添加可变项的情况下克服这一问题?

Make
LegacyCode::isProcessName
const:

bool LegacyCode::isProcessName(char* _sName,char* _pName,char* _szProcessName) const;

Make
LegacyCode::isProcessName
const:

bool LegacyCode::isProcessName(char* _sName,char* _pName,char* _szProcessName) const;
bool LegacyCode::isProcessName(char* _sName,char* _pName,char* _szProcessName) const;