Woa there Tex! Three are the things that jump out at me reading your code:
- switch statement from hell. At least call a function per case statement rather than piling all your code in one place
- mixing cstdio with iostream. Don't do it unless you're an expert. If you are an expert think twice about why you need to mix them.
- don't bother using exit(n); in main. return n; has the same effect.
The error you're getting is going to be something like "initialization of variable is skipped by switch statment." What that means is if someone enters 'f', 'g', 'h' the constructor for a won't be called. The flow of control goes galloping past, jumping over the initialisation of a. In your case this isn't a problem as a isn't used elsewhere. To get around this either stick everything that's currently in a case statement in a function OR use an additional level of scope around your case statement. I'd go for functions personally as scoped cases can get a bit ugly:
cout<<"how many number you want in queue:";
cin >> numbers;
printf("\n"); // Ugh, spit, gag, splutter, remove me!!
Anyway, hope that helps. If not shout and we'll see what we can do to improve our answers.
Edit: Realised that I'd said the wrong set of case statements avoided calling the constructor. Hopefully corrected that now!
tanks for the comments and sorry about my english
i fix the problem by putting the print function in the same case, my Q is why with the tamplate list i have larg scope and with deque i have to be in the same case ?
I used Eclipse years ago for developing Flex apps and was unimpressed. I picked it up again earlier this year when I played with android development but alas, again I was disappointed by the less than stellar performance. Damn you Java!
I'd be inclined to used Code::Blocks, it's compiled to native code, its available Win / Linux / Mac, 32 & 64 bit, will happily work with about a dozen or more compilers.
Also, without knowing the nature of the library it's impossible to know if this is a consideration or not, however - Code::Blocks has built-in support for using WxWidgets, which vastly eases the development of GUIs that are immediately portable.
It's also quite a small download - ~70MB for the IDE and GCC combined. Certainly worth a look imho.
Writing a platform independent library is fairly easy - don't use any features of the OS' you're targeting and don't make any assumptions about data sizes, object layout and anything else that the standard says is undefined.
If you're happy developing on Windows then don't bother with an IDE for Linux. Do all your development on Windows, checking at least once a day that everything builds using gcc. When I do cross platform development I use VC++2010 and gcc from mingw to make sure it builds. I've yet to write code I intended to be portable that didn't run on Linux that compiled on gcc from mingw.
For controlling the build I'd suggest one of three things:
- If your library is really small stick the g++ command line in a shell script and run that. Really small is a couple of source files.
- If your library is a bit bigger then write a makefile. mingw comes with two versions of make, both of which have (for simple projects) the same behaviour on Linux. I'd use this for libraries up to about 20 source files that you only want to build and run on a couple of platforms
- If your library is effing huge (10s of source files) and you want it to build and run on just about every Unixy platform on the planet use GNU autotools[^]. This is a set of (rather complicated) but very flexible tools that by writing a couple of simple files lets you build, test and run your code on loads of different platforms. I've used them to run code code I wrote on VC++ for windows on Linux, FreeBSD (both 32 and 64 bit) and Solaris.
Whatever you use I'd suggest eventually looking at the autotools if you ever want to do any cross platform stuff. They're pretty ubiquitous in the GNU world - whenever you ./config a package on Linux you're using them.
Oh, one thing I forgot to mention up top... If you need stuff usually supplied by the OS have a dig around for a library that already does it. Three libraries I use a lot are boost [^](it's a test bed for new libraries that might be standardised one day and has sorts of useful stuff - I've used it for date/time, filesystem support, threads, interprocess comms, shared and unique pointers before were in the standard), OpenSSL [^](all your crypto needs admittedly with the most bent interface you've ever seen) and libcurl [^](everything for HTTP/FTP/GOPHER client development).
This is usually done by having a Windows service that watches over your program.
There are several such programs available - Search for Application Watchdog[^]
Windows from Vista onward also supports Application Recovery and Restart[^] that you can use to have Windows restart your application in case of an unhandled exception.
«_Superman_» I love work. It gives me something to do between weekends.
Developing whatch dog on windows is very easy, all you need to create a named mutex from the process (program) needed to moniter, and from your moniter process, wait for that mutex handle to be closed. If it get closed than restart your program.
If you are a Linux user than crontab is your friend, use crontab instead of develop new watchdog so that you can spent time to find out why you program is crashing.
Is anyone aware of a 'Task Manager Logging' App that can 'Capture and Record' most or all of the information viewable in Task Manager, sampled at regular intervals, in some form of Database. One of our clients experiences quite extensive memory leaks in Windows XP. We are confident that it is not our software, but it is a case of 'It only started happening after your stuff was installed' We would like to run something that takes a SnapShot, Starters say every fifteen minutes, and upon notifyable events, such as Process Starts or Stops.
Alternatively, is there a way to configure 'MS Windows Event Logging' to do the same.
I am just trying to figure out Why this customer gets 'Low virtual Memory' messages after two or three days running, and the system grinds to a Halt when that happens.
I build default MFC doc / view app and
I get same error with or without including either iostream or iostream.h.
To me that indictates that iostream does not define namespace.
Can it be defined somewhere else?
If I get a syntax error the compiler does not recognize the "namespace" as valid syntax.
So it has to be defined to be vaild. Does not?
For example "if" is defined in similar way, but compiler flags "iff" as undeclared identifier.
I am just trying to find some reason why I am getting same syntax error with or without including iostream.
You've probably left a semicolon, closing brace, closing parentheses or similar off the previous thing in the .h file.
Just out of interest, if you ever want to know if you can use a feature in a compiler just lop the code out and stick it in a .cpp file somewhere, making sure it's not dependent on any other code. In this case had you stuck:
in a source file you'd have seen it compiles just fine in VC++6.0. As far as anything can be regarded as "compiling just fine" on that clunky piece of old rubbish.
Last Visit: 31-Dec-99 18:00 Last Update: 29-Apr-17 5:56