[英]Am I really this stupid : this = 0x7ffffffe
I have a very simple class stub - i just started making it: 我有一个非常简单的类存根-我刚刚开始学习:
class CJSScript
{
public:
CJSScript(std::string scriptfile);
~CJSScript(void);
private:
std::string scriptname;
};
CJSScript::CJSScript(std::string scriptfile)
{
size_t found = scriptfile.find_last_of("/\\");
scriptname = scriptfile.substr(found+1);
printf("should load %s now...", scriptname);
}
however in that constructor i get an exception, this
apparently is set to 0x7ffffffe
但是在该构造函数中,我得到一个异常, this
显然设置为0x7ffffffe
main program is 主程序是
int _tmain(int argc, _TCHAR* argv[])
{
CJSScript* test=new CJSScript("./script/test.js");
system("pause");
return 0;
}
what the hell is going on. 这到底是怎么回事。 i thought i had basics behind me a long time ago but this is a compromitation. 我以为我很久以前就掌握了基础知识,但这是一种妥协。 of me or the compiler :) 我还是编译器:)
debugger dump : 调试器转储:
Win32Project3.exe!_output_l(_iobuf * stream, const char * format, localeinfo_struct * plocinfo, char * argptr) Line 1649 C++
Win32Project3.exe!printf(const char * format, ...) Line 62 C
Win32Project3.exe!CJSScript::CJSScript(std::basic_string<char,std::char_traits<char>,std::allocator<char> > scriptfile) Line 11 C++
Win32Project3.exe!wmain(int argc, wchar_t * * argv) Line 38 C++
Win32Project3.exe!__tmainCRTStartup() Line 240 C
printf
doesn't know how to deal with string
objects. printf
不知道如何处理string
对象。 You need to pass a const char*
: 您需要传递一个const char*
:
printf("should load %s now...", scriptname.c_str());
This is an issue of type safety. 这是类型安全的问题。 For this reason, among others, I prefer using streams. 因此,除其他外,我更喜欢使用流。
cout << "should load " << scriptname << " now...";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.