Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MFC
Hi and good morning to all the users of code project,
i'm now try to make a program with an additional of .cpp file, or may be will more then 1, but i never make it before, and i wonder what is my problem, even I already insert my header file into my main cpp file, at the same time I already make the declaration, but when i tried to compile my code, it shown me that, I haven't declare it, but actually i already declare it in my main cpp files,*please take note that i already insert my main header file into my secondary cpp file as well* then i tried to make another declaration into my secondary cpp*Actually i know it won't work, but i just try my luck*, another error messagebox show that, i had make my declaration in the main page, so any suggestion or solution for me??
 
thanks,
 
Rgds,
 
illm1995
Posted 30-Sep-12 15:52pm
Comments
Sergey Alexandrovich Kryukov at 30-Sep-12 22:24pm
   
Calm down, it's not fatal. If you knew it won't work, why pointless "trying your luck". You did not even properly explained the problem. Just do everything properly, and do it by yourself.
--SA
illm1995 at 30-Sep-12 22:32pm
   
for an example,
I declare int a in main .cpp file,
when i try to call it in my secondary .cpp file, it show me the error message box that i haven't make the declaration*int a" yet
Sergey Alexandrovich Kryukov at 30-Sep-12 23:07pm
   
First of all, there is no such thing as "call a file". After all, make a simplest code sample: some 3 files, one extra declaration, and show it all, with file names. Here, we almost don't have members who only compiled an application with only one file, I believe, most of us are a bit more advanced than that, so, will sort it out somehow... :-)
--SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

In your second .cpp, make it as extern
extern int a;
  Permalink  
Comments
illm1995 at 1-Oct-12 0:00am
   
Thank you, but now I'm facing another problem in my 2nd cpp as well, that are messagebox, the compiler did not recognize the command of 'L' and 'MB_OKCANCEL', 'MB_ICONWARNING'.. is there any solution??
 
Thanks You,
 
Rdgs,
 
Illm1995
illm1995 at 1-Oct-12 0:01am
   
Sorry for interrupt you anyway. @@
Kuthuparakkal at 1-Oct-12 0:16am
   
Add winuser.h
or declare like this :
private const uint MB_OK = 0x00000000;
The other uint values :
MB_OK is 0x00000000L
MB_OKCANCEL is 0x00000001L
MB_ICONWARNING is 0x00000030L
illm1995 at 1-Oct-12 0:25am
   
Sorry to say, it does not work :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 414
1 Maciej Los 180
2 Richard MacCutchan 140
3 DamithSL 129
4 Kornfeld Eliyahu Peter 119


Advertise | Privacy | Mobile
Web04 | 2.8.140709.1 | Last Updated 30 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid