用于支持关键字的类。 [英] Class to support keywords.
问题描述
我想编写一个类,支持对属于
C ++编程语言的关键字的操作。以下程序反复提示
用户输入关键字,直到最终输入''explicit':
#include< iostream>
#include" KeyWord.h"
int main()
{
KeyWord word;
while(std :: cin>> word&& word!=" explicit");
返回0;
}
在上面的
程序中支持KeyWord功能的类会是什么样的?这样的实现的细节是什么? >
级?如果要使用另一套
关键字,将需要对实施进行多少更改?
我将非常感谢代码形式的帮助以及讨论。谢谢。
I want to write a class that supports operations on keywords belonging to
the C++ programming language. The following program repeatedly prompts the
user for a keyword until ''explicit'' is finally entered:
#include <iostream>
#include "KeyWord.h"
int main()
{
KeyWord word;
while (std::cin >> word && word != "explicit");
return 0;
}
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.
推荐答案
Jason Heyes写道:
Jason Heyes wrote:
我想编写一个类,支持对属于
用户输入关键字,直到最终输入''explicit':
#include< iostream>
#include" KeyWord.h"
int main()
{
KeyWord字;
while(std :: cin>> word&& word!=" explicit" );
返回0;
在上面的程序中支持KeyWord功能的类是什么样的?实现的细节是什么?这样的课程?如果要使用另一组关键字,则需要对实现进行多少更改?
我希望以代码和讨论的形式提供帮助。谢谢。
I want to write a class that supports operations on keywords belonging to
the C++ programming language. The following program repeatedly prompts the
user for a keyword until ''explicit'' is finally entered:
#include <iostream>
#include "KeyWord.h"
int main()
{
KeyWord word;
while (std::cin >> word && word != "explicit");
return 0;
}
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.
// KeyWord.h
#include< iostream>
# include< string>
typedef std :: string KeyWord;
// KeyWord.h
#include <iostream>
#include <string>
typedef std::string KeyWord;
* Jeff Schwab:
* Jeff Schwab:
// KeyWord.h
#include< iostream>
#include< string>
typedef std :: string KeyWord;
// KeyWord.h
#include <iostream>
#include <string>
typedef std::string KeyWord;
嗯,你不需要< iostream>那里。
-
答:因为它弄乱了人们通常阅读文字的顺序。
问:为什么这是一件坏事吗?
A:热门发布。
问:usenet和电子邮件中最烦人的是什么?
Well, you don''t need <iostream> there.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jason Heyes写道:
Jason Heyes wrote:
我希望以代码和讨论的形式提供帮助。谢谢。
I would appreciate help in the form of code as well as discussion. Thanks.
也许只是我。
但是根据你的描述,我不清楚你想要达到的目标。 />
-
Karl Heinz Buchegger
kb ****** @ gascad.at
这篇关于用于支持关键字的类。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!