473,406 Members | 2,956 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,406 software developers and data experts.

Wrap entry point main() in C++

Hi,

I would like to know how usually you wrapp an ugly main fonction into a
;-) C++ method.
I would like to write a simple console application that read a XML file
so it starts like this :
I was thniking about defining a MyApp class with a Init and Run methode:
class MyApp
{
public:

....
void Init(int argc, char* argc[]);
int Run();

};

int main(int argc, char* argv[])
{
MyApp myApp;

myApp.Init(argc, argv);
return myApp.Run();

}

Better idea ?

Dec 12 '07 #1
1 1908
On 2007-12-12 08:38, mosfet wrote:
Hi,

I would like to know how usually you wrapp an ugly main fonction into a
;-) C++ method.
I would like to write a simple console application that read a XML file
so it starts like this :
I was thniking about defining a MyApp class with a Init and Run methode:
Why would you, in main() you typically perform a number of actions that
have nothing to do with any of the objects, such as verifying that the
supplied arguments are valid, initialising the "environment", and so on.
Once that is done you can start creating the objects that and call their
methods. Notice thought that for some applications the objects are only
used to get a better structure and the flow of the program is driven by
stand alone functions. If you come from a Java background this might
sound a bit strange but that is just because Java lacks support for
normal functions, instead they use static member functions and such.

--
Erik Wikström
Dec 12 '07 #2

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

Similar topics

13
by: Laurent Schall | last post by:
I experience a problem where starting an application compiled with visual C++ 6 SP5 does not execute the function main(int argc, char **argv) and exit immediately with code 1 (0x1). Putting main...
6
by: aneesh | last post by:
Hi all, I would like to know whether we can specify another function instead of main as entry point. Thanks Aneesh
8
by: name | last post by:
Back again for more critique... <grin> ------------------------------------------------ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <limits.h> #define MAX 10000
1
by: I am Sam | last post by:
Hi Everyone, I am new to Server control development and I am wondering how do I define the entry point for a server control? In a regular page you define Page_Load as an entry point and in a...
8
by: FUGATO | last post by:
I need to help in my assignment. I need to wrap a text with the following indications: 1.If you have reached the end of the line (number of characters on this line >= 40) AND you have reached the...
5
by: Mike in Santa Rosa | last post by:
I'm trying to get a simple c# app built that can launch/manipulate an excel workbook, sheet. I've chased down several examples and can't any of them to work. So I must be doing somethnig obviouslt...
2
by: bboule | last post by:
Hi I have developped a dll that I want to use in another program ! here is my code : using System; using System.Collections.Generic; using System.Text; namespace NameSpace
5
by: pamela fluente | last post by:
I have been posting this question with no success. I do not know if I am not being clear of the question is too difficult :-)) or unclear. It seems to me that the need to wrap a collection is quite...
5
by: Premkumar | last post by:
a.cpp ---------------------------------- #include <iostream> using namespace std; void mymain() { cout<<"my-main"<<endl; } ----------------------------------
1
by: nicolas.hognon | last post by:
Hello, With non CLR C++ I am used to have a static library (MyMain.lib) which defines the main entry points depending on the plateform (windows, unix, mac os x, ps3, ...). We are planning to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.