473,387 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

main function not found

Hello All,
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 ?
Many thanks in advance.
Robert

Jul 23 '05 #1
4 2917

wo*********@yahoo.com wrote:
Hello All,
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 ?
Many thanks in advance.
Robert


This is an MFC application, there is no 'main'. There is
'InitInstance', but no 'main'. Try google for "cwinapp mfc" and you
should find some information.

Hope this helps,
-shez-

Jul 23 '05 #2

Check out below.

wo*********@yahoo.com wrote:
Hello All,
From a book where I have learned C++ it says that each application
must have at least one
function which is the main() function.
Correct.
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 ?
Inorder to implement complete OOPS in C++, we can declare and implement
a class, which when initialized as global object, calls the constructor
of that particular class. This does n't need a main function. This
method is utilized in MFC(Microsoft Foundation Classes). So,
constructor of MyToolApp is the start of the program. But, MFC class
CWinApp calls the InitInstance() method in that particular class, so
InitInstance is the main method of the program.
Many thanks in advance.
Robert


Jul 23 '05 #3
On 6 Feb 2005 04:41:44 -0800, "wo*********@yahoo.com"
<wo*********@yahoo.com> wrote in comp.lang.c++:
Hello All,
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 ?
Many thanks in advance.
Robert


The MFC (Microsoft Foundation Classes) which are by the way off-topic
here, bury the main() function internally.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Jul 23 '05 #4
* 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?
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

192
by: Kwan Ting | last post by:
The_Sage, I see you've gotten yourself a twin asking for program in comp.lang.c++ . http://groups.google.co.uk/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&th=45cd1b289c71c33c&rnum=1 If you the oh so mighty...
4
by: Jacek Dziedzic | last post by:
Hi! First of all, I hope my problem is not too loosely tied to the "standard C++" that is the topic of this group. I have some code that exhibits a strange behaviour: on one computer, where I...
19
by: Steven T. Hatton | last post by:
The short sample program listed below has some features that I find to be bad style. In particular, they fail to communicate the connection between names used in this program and the location in...
16
by: junky_fellow | last post by:
I was reading the various posts in this newsgroup, and found that main function should be declared as int main(void) // if no arguments are passed to main i wanted to know whats the purpose of...
16
by: leeaby | last post by:
Hi, I will appreciate your assistance. Can we write a c code which do not contain main() I have heard that this is possible. Is it really possible? Thanks for your help in advance lee
8
by: Rody Reulen | last post by:
I made an console application with Visual Basic .net. Visual Basic will automatically create the sub procedure main for you. I try to convert the main procedure to a function. During the...
7
by: Terry | last post by:
I have a Mainform with a Statusbar. When opening another form or doing some processing I want to display info in the Statusbar of the Mainform. I have read a lot of articles on this & have come up...
6
by: flash | last post by:
write a program that manipulates arrays of integers. The main program should call three functions: Insert, Delete, and Search. The Insert function should call a function Sort that sorts the array. ...
8
by: Michal Nazarewicz | last post by:
Hi, What does returning 0 from main() mean according to C89/C90 standard? I've found that in C99 it means successful termination (7.20.4.3p5) however as I'm editing book on C at Polish Wikibooks...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.