I need help with this code

Constructer is abnormally called again n again.... add these file 2 a project n run ...i've given given constant messages in da code to explain the problem!

Hit (1) two tyms i.e GetInput function in da menu.... u'll get 2 knw wat da problem is...

i've created an array of objects ....n when i jump 2 da next index da values of old index's r chenged to da default values ( da values assinged in constructer)!!!!

i've attached the files of prject...!

Recommended Answers

All 2 Replies

Please write complete words. Your txting shorthand makes my brain hurt.

The first thing I see is within your main() in main.cpp, you're recursively calling main(). Don't ever do that; a number of compilers won't even compile it. main() is the entry point from the operating system into your program. Instead, simply move the printing of the menu into the top of the do { ... } while(); loop.

When you declare your static AR::stdcount variable in AR.cpp, assign it an initial value at the same time. E.g. int AR::stdcount = 0;

Avoid using system() calls in your code. There are usually ways to do what you want via function call into a library without executing a separate shell. And specifically avoid coding system("cls"); since the cls command is not portable across shells or operating systems, and even if the user is interacting with the program in a shell/console/terminal, the program should not assume it is the only thing running in, or that it has any control over, the shell/console/terminal. Same goes for system("pause"); -- instead, prompt the user to press a key or enter a value to continue.

In AR::showAll(), why are you incrementing i in the loop-expression, and decrementing t in the loop-body? You're only going to get half the items that way!

At line 15 in GS.cpp, remove the int declaration, qmarks2 is already declared as an int in GS.h. With the extra int, you're creating a temporary local variable which masks the instance member. The temporary variable is destroyed when the constructor returns, and the member with the same name is left uninitialized. But it doesn't look like your code actually uses the GS class for anything, so I don't know why you posted it.

Sorry about my shorthand text, I will try to be more formal in my writing next time!
And yeah i got the problem! thanks alot for your response!
The main mistake was that i was calling the main() function again and again and everytime when the control return back to the starting of body of main() ,the instances/variables/arrays are re created in the memory!
So, I was loosing my data of first index after calling the GetInput() function ,which was the main problem. I got it! Thanks again!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.