Click here to Skip to main content
12,819,248 members (28,863 online)
Rate this:
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??



Posted 30-Sep-12 16:52pm
Sergey Alexandrovich Kryukov 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.
illm1995 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 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... :-)

1 solution

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

Solution 1

In your second .cpp, make it as extern
extern int a;
illm1995 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,


illm1995 1-Oct-12 0:01am
Sorry for interrupt you anyway. @@
Kuthuparakkal 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 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
Top Experts
Last 24hrsThis month

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100