CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Threaded View

  1. #1
    Join Date
    Aug 2011
    Posts
    21

    Arrow How to use the variables in another class

    Hi all,
    I have class CTestView and CChartDlg , I want to use an array of CTestView in the other class, here is the code:
    Code:
    class CTestView : public CView
    {
            ...........................
    public:
    	int  num[10]
    	void fun();
    
             ...................................	
    };
        .........................
     void CTestView::fun()
    {
          ................
         for (int i=0;i<10;i++)
               num[i]=i;
         .........
    }
    the other class:
    Code:
    class CChartDlg : public CDialog
    {
    public:
          CChartDlg(CWnd* pParent = NULL); 
       .......................
    protected:
         afx_msg void OnCreate();
       .........................
    }
     ...............................
    void CChartDlg::OnCreate() 
    {  ...............
       // I want to use num[0]~num[9] in this function.
    
    }
    I want to use num[0]~num[9] in class CChartDlg
    I tried CCentriodView getv;
    but getv.num[0] is not the right num ,can anyone help me with this?Thank you !
    Last edited by Angela2010; December 27th, 2011 at 06:21 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured