|
|
Well, I have a question to ask, as a starting point: Why the hell are you doing this in Turbo C++? Not to be rude, but... the website for it doesn't even work anymore. |
using namespace std;
Turbo C/C++ probably doesn't require this, but current C++ compilers (which you should be using) do require it if you don't qualify your references to the std:: namespace. void Quiz::Help ()
choice
, ch1
, ch2
, etc is out of scope... you must use a public function to access the object member.Well, I have a question to ask, as a starting point: Why the hell are you doing this in Turbo C++? Not to be rude, but... the website for it doesn't even work anymore. |
I've heard from some friends from India that a bunch of schools there use really out-of-date compilers like Turbo C/C++. I'm not sure where this guy is from, but maybe it's the same situation. |
Line 4: You need using namespace std; Turbo C/C++ probably doesn't require this, but current C++ compilers (which you should be using) do require it if you don't qualify your references to the std:: namespace. Line 21,28,35: Illegal use of void. Did you intend ()? Your compiler didn't even detect this. Line 52: choice is undefined. You have to define a variable before you can do cin to it. Line 7: choice is a private member of your Quiz class. You can't access it directly from main(). This is the cause of all your undefined variable diagnostics. Note that each of your functions (help, legal, about, etc) are stand-alone functions. They are not members of your class. If you want to code functions that are members of your class, you need to use the class name in the function definition. e.g. void Quiz::Help () Line 55 and too many other places to itemize: When you do a function call, do NOT put the word void in front of the function call. |
using namespace std;
maybe because Turbo C++ doesn't require this.()
after the bInd, iInd and eInd functions...e.g. |
void Quiz::Help ()
@OP: choice , ch1 , ch2 , etc is out of scope... you must use a public function to access the object member.and, yeah, don't use TC++ that's bad for your health :D |
public:
section.
using namespace
or qualifying library references with std::, that I brought up the issue of an obsolete compiler. If you're going to post on this site, you're going to get help relevant to a standards compiliant C++ compiler. In other words, Turbo C++ does not comply with even the C++2003 standard. As for namespaces, namespaces were introduced in 1998. If Turbo C++ does not support namespaces, that is how out of date your compiler is. |
The OP has already stated that he doesn't have a choice for which compiler to use. And since this is cplusplus.com and not C++11.com or C++14.com, I for one am willing to help. The big problem here is that you have all the data in member variables but then code is all in global functions. Some of this data should be in local variables. Your main(), help(), legal() and about() functions all contain code to prompt the user for the same action. That code should all be in main(). |
|
|
|
|
|
|
Line 3: Why are you including process.h? Line 9: making these variables public is poor style. 1) Line 52, et al: choice is a public member of Quiz. If you want to reference it here, you need to reference an instance of Quiz. e.g. q1.choice. However, better style would have been to make choice a local variable inside main. It's not used outside of main and serves no purpose as a member of Quiz. Note: main has no instance of Quiz. line 68: You're missing a } to terminate main(). If you used any kind of indentation, this would have been obvious. 2) Line 69, 95, 125: about(), legal() and help() are global functions, not members of your class. However, you've declared them as members at lines 13-15. about, legal and help need to be prefixed by Quiz:: I pointed this out to you previously.
3,4) These errors are caused by the missing } at the end of main. 5) Lines 156-160: These lines are not part of any function. Where do they belong? Shouldn't they be in main()? Lines 55,58,61,64: You're calling global functions, but they've not been defined with function prototypes. You seem confused as to whether help(), about(), legal() and start() are global functions or members of your class. If they're global functions, they need function prototypes (and get rid of lines 13-16) or if they're members of your class, they need to be called through an instance of Quiz. Make up your mind. Line 168,174: The capitialization of lchoice and tchoice does not match line 9. You declare highScore() and bScience() as member functions, but you have not implemented these function.s However, you attempt to call these functions. This will result in linker errors. |
Second, I want to see a fresh screen each time a new function is called or a new question is displayed which I can't see in your code. |
|
|
As my comment at line 5 indicates, clrscr() is not a standard function. i.e. It does not exist in a standard C++ compliant library. However, it does exist in Turbo C++, so you can just delete my lines 5 and 6 and use the Turbo C version. I inserted lines 5 and 6 so that I would not have to remove all your calls to clrscr(). An alternative is the following:
However, the use of the system() call is generally considered poor practice. |
|
|
eof()
? If yes, then how?bScience()
:
|
|
bScQues()
:
|
|
Line 10: Your delimiter has no character between the single quotes. That is not a valid character literal. Exactly what character do think getline would be looking for if that were legal? |
|
|