*
wo*********@yahoo.com:
From a book where I have learned C++ it says that each application must
have at least one function which is the main() function. Now I have the
source code of a C++ program from someone else. But whatever I am doing
to search for the main function, I can not find it. There is a very short
description of the program in a Readme file where it says that the main
program is located in a class "MytoolApp". I've had a look in this class
which seems to be derived from the "CWinApp" class. What is a "CWinApp" class
? I could not find any function called main() in this "MytoolApp" class.
Can anyone explain this to me ?
There are two ways a C++ program can apparently or actually be without a
'main' function, and both probably apply in your case.
First, that you're using an application framework that has a 'main'
function that in turn calls a function (e.g. a member function) in
your code. If you don't have the application framework source code
you'll not see 'main' anywhere. Even though it might be there.
Second, the standard differentiates between _hosted_ and _freestanding_
implementations of the language. Freestanding is meant for e.g. embedded
systems programming, where it's impractical to provide all the features
of the standard library, or even a 'main' function. For purposes of formalism
most Windows C++ implementations must be regarded as freestanding, because
they allow and to a certain practical extent require other startup functions
than 'main', e.g. 'wmain', 'WinMain' and 'wWinMain' (a Microsoft convention);
and these names might be hidden in macros, e.g. 'tmain' (a macro).
What you have seems to be an MFC Windows GUI application, as Jack Klein
pointed out, and if so then both apply: first, you're using an application
framework that provides the startup function, and second, the C++
implementation is a freestanding one where most probably the startup function
is not 'main' but (non-standard, implementation-defined) 'WinMain'.
Hope this helps,
- Alf
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?