简体   繁体   English

我真的是这个愚蠢的人吗:this = 0x7ffffffe

[英]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.

相关问题 我很确定我犯了一个愚蠢的错误,但是这段代码给出的输出太长而无法阅读 - I am pretty sure I am making a stupid mistake, but this code gives out an output that is just too long to read 我是真的返回地址还是提及临时地址 - Am I really returning address or reference to a temporary 在这种情况下,我是真正复制字节还是复制字符? - Am I really copying the bytes or am I copying characters in this case? “x = ++ x”是不是真的未定义? - “x = ++x” is it really undefined? 为什么我得到“声明与(x)不兼容”? - Why am I getting a “declaration is incompatible with (x)”? 2D阵列内存泄漏-应该很简单,我觉得很愚蠢 - 2D Array Memory Leak - Should be easy, I feel stupid Cocos2d不容许C ++文件吗? (我真的对CAStreamBasicDescription感到困惑) - Cocos2d does not tolerate C++ files? (I am really stuck with CAStreamBasicDescription) 〜i真的等于i!= -1吗? - Is ~i really equivalent to i != -1? gtest和cstdarg之间是否存在不良交互,或者我真的错过了这里的堆栈粉碎吗? - Is there a bad interaction between gtest and cstdarg, or am I really missing the stack smash here? 如何快速计算C ++中6x6矩阵的行列式? - How do I calculate the determinant of a 6x6 matrix in C++ really fast?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM