调试器没有命中断点

时间:2014-01-26 15:56:21

标签: c++ debugging

简单的代码,在main(这篇文章的底部)有一行代码,但VS2008将此行标记为无法访问!!! 有人可以看看,告诉我它是怎么回事。 请注意,如果我在类Reader中删除标记为// DELETED TO WORK的行,则此代码奇迹般地起作用。尝试了很多东西,指向调试器到源代码等,以上都没有。 需要帮助。

谢谢。

// AClass.hpp

class AClass
{
    int x ;  
public:
    AClass(void);
    ~AClass(void);
};  

// AClass.cpp

#include "AClass.hpp"

AClass::AClass(void)
{
    int a = 1;
    if (a++)
    {
        a = a + 1;
    }
    else
    {
        a = a -1;
    }
}

AClass::~AClass(void)
{
}

// Reader.hpp

#include <string>
#include "AClass.hpp"
class Reader
{
private:
    std::string str_;
    //Tokenizer tokenizer_;
    AClass ac_;//DELETED TO WORK
public:
    Reader(void);
    ~Reader(void);
    std::string read();
};

// Reader.cpp

#include "Reader.h"
#include <iostream>


Reader::Reader(void)
{
}

Reader::~Reader(void)
{
}

std::string Reader::read()
{

    std::getline(std::cin,str_);//read input

    return str_;//result of calculations is in str_
}

// main.cpp中

#include "Reader.h"


int main(int argc, char* argv[])
{


    Reader reader;
    try
    {
        reader.read();//BREAKPOINT SET ON THIS LINE IS MARKED BY VS AS UNREACHABLE!!!!!!
    }
    catch(...)
    {
        std::cerr << "Something is wrong";
    }
    return 0;
}

0 个答案:

没有答案