Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

accessing a variable from other class

Status
Not open for further replies.

Vervoortje

Technical User
May 5, 2003
6
BE
I have a Dialog based project in my first(standard) dialog (CFLADlg) i have a variable called m_bestand. i want to acces m_bestand in the class CAnalyze, CAnalyze is the class generated by the dialog box i made ofcourse called Analyze.

How do i do that.

reasonable Error : error C2065: 'm_bestand' : undeclared identifier

Declaration of m_bestand

class CFLADlg : public CDialog
{
// Construction
public:
CString m_bestand;
CFLADlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CFLADlg)
enum { IDD = IDD_FLA_DIALOG };
CString m_bestanddisplay;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFLADlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CFLADlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnDestroy();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnButtonOpen();
afx_msg void OnButtonSyntax();
afx_msg void OnButtonInterval();
afx_msg void OnButtonRun();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

I Tried just to include CFLADlg.h in Analyze.cpp

Is there anything else you need to know to help me?

entire project in rar can be found on :

Thx in advance
 
Since m_bstand is a member of the class CFLADlg it can only be accessed through an instance of that class.

Code:
CFLADlg dlg;
cout << (LPCSTR)dlg.m_bestand << endl;

-pete
[sub]I just can't seem to get back my IntelliSense[/sub]
 
I would further recommend that you restrict access to m_bstand to a &quot;get&quot; function (making the member private, then having its value returned through a public &quot;get&quot; function). This promotes data integrety and class maintainability.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top