听的不是很清楚啊。贴出来Look

解决方案 »

  1.   

    我把代码贴出来吧。
    我在主程序里有两句这样的代码:
    C1* pC1 = new C1;
    C2* pC2 = new C2;三个类的头文件为:
    // C.h: interface for the CC class.
    //
    //////////////////////////////////////////////////////////////////////#if !defined(AFX_C_H__1046D5D9_7945_4EC1_8426_0CEB56355350__INCLUDED_)
    #define AFX_C_H__1046D5D9_7945_4EC1_8426_0CEB56355350__INCLUDED_#if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000class CC  
    {
    public:
    CC();
    virtual ~CC();};#endif // !defined(AFX_C_H__1046D5D9_7945_4EC1_8426_0CEB56355350__INCLUDED_)
    // 1.h: interface for the C1 class.
    //
    //////////////////////////////////////////////////////////////////////#if !defined(AFX_1_H__FC17ACA9_92B7_438E_A3B6_EADC9B987DCD__INCLUDED_)
    #define AFX_1_H__FC17ACA9_92B7_438E_A3B6_EADC9B987DCD__INCLUDED_#if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000#include "C.h"class C1 : public CC  
    {
    public:
    C1();
    virtual ~C1();public:
    bool m_bRight;};#endif // !defined(AFX_1_H__FC17ACA9_92B7_438E_A3B6_EADC9B987DCD__INCLUDED_)
    // 2.h: interface for the C2 class.
    //
    //////////////////////////////////////////////////////////////////////#if !defined(AFX_2_H__4C61BD3B_8E54_4650_9E93_BB824D6E66DF__INCLUDED_)
    #define AFX_2_H__4C61BD3B_8E54_4650_9E93_BB824D6E66DF__INCLUDED_#if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000#include "C.h"class C2 : public CC  
    {
    public:
    C2();
    virtual ~C2();};#endif // !defined(AFX_2_H__4C61BD3B_8E54_4650_9E93_BB824D6E66DF__INCLUDED_)三个类的Cpp文件是:// C.cpp: implementation of the CC class.
    //
    //////////////////////////////////////////////////////////////////////#include "stdafx.h"
    #include "hhhh.h"
    #include "C.h"#ifdef _DEBUG
    #undef THIS_FILE
    static char THIS_FILE[]=__FILE__;
    #define new DEBUG_NEW
    #endif//////////////////////////////////////////////////////////////////////
    // Construction/Destruction
    //////////////////////////////////////////////////////////////////////CC::CC()
    {}CC::~CC()
    {}
    // 1.cpp: implementation of the C1 class.
    //
    //////////////////////////////////////////////////////////////////////#include "stdafx.h"
    #include "hhhh.h"
    #include "1.h"#ifdef _DEBUG
    #undef THIS_FILE
    static char THIS_FILE[]=__FILE__;
    #define new DEBUG_NEW
    #endif//////////////////////////////////////////////////////////////////////
    // Construction/Destruction
    //////////////////////////////////////////////////////////////////////C1::C1()
    {
    m_bRight = true;}C1::~C1()
    {}// 2.cpp: implementation of the C2 class.
    //
    //////////////////////////////////////////////////////////////////////#include "stdafx.h"
    #include "hhhh.h"
    #include "2.h"#ifdef _DEBUG
    #undef THIS_FILE
    static char THIS_FILE[]=__FILE__;
    #define new DEBUG_NEW
    #endif//////////////////////////////////////////////////////////////////////
    // Construction/Destruction
    //////////////////////////////////////////////////////////////////////C2::C2()
    {     //运行到这里的时候C1类的m_bRight出错。}C2::~C2()
    {}
      

  2.   

    你的监视变量是怎么写的,pC1->m_bRight, 还是m_bRight,如果是第二种的话,是出了C1的范围,m_bRight就对于当前的范围无效(在C2::C2中)