能帮我这个程序吗?
C++ 的爱好者们@@?
本人是一菜鸟级的fan,在了解到连接列表的有如下程序,欢迎各位help,talk,
驱动程序:
0 #include "def0514.h"
1 #include "node0601.h"
2 int main()
3 {
4 Node head('a');
5 head.Insert('b');
6 int Count=head.HowMany('a')
7 cout<<"There are" <<count<<"instances of a \n";
8 cout=head.HoeMany('b');
9 cout<<"There are"<<count<<"instances of b\n";
10 cout<<"\n\n Here's the intire list: ";
11 head.Display();
12 cout<<endl;
13 return 0
14 }
实现 Node
0 #inclue <iostream>
1 using namespace std;
2
3 #include "node0601.h"
4
5 Node:: Node(char c):
6 myChar(c),nextNode(0)
7 {
8 }
9
10 Node:: ~Node()
11 {
12 if(nextNode)
13 delete nextNode;
14 }
15
16
17 void Node:: Display() const
18 {
19 1cout<<myChar;
20 if(nextNode)
21 nextNode->Display();
22 }
23
24
25 int Node::HowMany(char theChar)const
26{
27 int myCont=0
28 if(myChar==theChar)
29 myCount++;
30 if(nextNode)
31 return myCount+nextNode->HowMany(theChar);
32 else
33 return myCount;
34 }
35
36 Void Node::Insert(char theChar)
37 {
38 if(!nextNode)
39 nextNode=new Node(theChar);
40 else
41 nextNode->Insert(theChar);
42 }
def0514.h
0 #ifndef DEFINED
1 #define DEFINED
2
3 #include<iostream>
4 using namespace std;
5
6 const char alpha[]="abcedfghijklmnopqrstuvwxyz";
7 const int minPos=2;
8 const int maxPos=10;
9 const int minLetters=2;
10 const int maxLetters=26;
11
12 #define DEBUG
13
14 #ifndef DEBUG
15 #define ASSERT(x)
16 #else
17 #define ASSERT(x) \
18 if(!(x)) \
19 { \
20 cout<<"ERROR!! Assert"<<#x<<"failed\n"; \
21 cout<<"on line"<<_LINE_<<"\n \
22 cout<<"infile"<<_FINE_<<"\n"; \
23 }
24 #endif
node类声明
0 class Node
1 {
2 public:
3 Node(char c);
4 ~Node();
5 void Display()const;
6 int HowMany (char c) const;
7 void Insret (char c);
8
9 private:
10 char GetChar();
11 Node *GetNext();
12 char myChar;
13 Node *nextNode;
14}
能详细介绍一下各个方法的实现情况吗?(含this指针的方法,)
他们都太抽象了,能明了一些吗?