J
Jason Heyes
This is a revised version of a post entitled "Class to support keywords".
Please reply to this post instead of the old one.
The following program repeatedly prompts the user for C++ keywords until
'explicit' is entered. If the user fails to enter a valid keyword, the
program terminates.
#include <iostream>
#include "KeyWord.h"
int main()
{
KeyWord word;
while (std::cin >> word && word != "explicit");
return 0;
}
The following two lines of input will terminate the program:
do for while explicit
if else elseif virtual instanceof
The input given by the string "public private switch" will not.
What would a class that supports the functionality of KeyWord in the above
program look like? What are the details of the implementation of such a
class? How many changes to the implementation would be required if another
set of keywords was to be used instead?
I would appreciate help in the form of code as well as discussion. Thanks.
Please reply to this post instead of the old one.
The following program repeatedly prompts the user for C++ keywords until
'explicit' is entered. If the user fails to enter a valid keyword, the
program terminates.
#include <iostream>
#include "KeyWord.h"
int main()
{
KeyWord word;
while (std::cin >> word && word != "explicit");
return 0;
}
The following two lines of input will terminate the program:
do for while explicit
if else elseif virtual instanceof
The input given by the string "public private switch" will not.
What would a class that supports the functionality of KeyWord in the above
program look like? What are the details of the implementation of such a
class? How many changes to the implementation would be required if another
set of keywords was to be used instead?
I would appreciate help in the form of code as well as discussion. Thanks.