64,654
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <stdio.h>
using namespace std;
class threeletterchain;
class threeletternode
{
friend class threeletterchain;
public:
threeletternode(const char e){data[0] = e;}
private:
char data[3];
threeletternode *link;
};
class threeletterchain
{
public:
void insertback (const char &e)
{
if(first)
{
last->link=new threeletternode(e);
last=last->link;
}
else
first=last=new threeletternode(e);
};
private:
threeletternode *first;
threeletternode *last;
};
main()
{
threeletternode a('a');
threeletterchain b;
return 0;
}
#include <iostream>
//#include <iostream.h>
#include <stdio.h>
class threeletterchain;
class threeletternode
{
friend class threeletterchain;
private:
char data[3];
threeletternode *link;
};
class threeletterchain
{
public:
void insertback(const char &e)
//void chain:: insertback (const char &e)
{
if(first)
{
last->link=new threeletternode;
last=last->link;
}
else
first=last=new threeletternode;
};
private:
threeletternode *first;
threeletternode *last;
};
int main()
{
threeletternode a;
threeletterchain b;
return 0;
}