|
-
March 23rd, 2004, 04:24 AM
#1
"extern" declaration
I'm not sure where should I declare my extern variable. let say is
extern char nbuffer[30];
nbuffer is a global variable, and defined in other source file.
Assuming I have MainDlg.cpp, Dialog1.cpp.
In my Dialog1.cpp
#include "MainDlg.h"
.....
void CDialog1::OnMyok()
{
//here I want to use global variable nbuffer, but got error!!!
GetDlgItemText(IDC_EditBox, nbuffer, 30);
CDialog::OnOK();
}
Then I declared nbuffer at MainDlg.h after the statement, not if it is right way to do.
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif //
extern char nbuffer[30];
But compilation gives me error "nbuffer" Undeclared identifier. Why ? and how to fix it ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|