首页 新闻 会员 周边 捐助

C++源代码问题,求救急用

0
悬赏园豆:50 [已解决问题] 解决于 2012-03-06 22:43

问题:怎样把下面的数据弄出来,储存在另一个文件里,不是已经用主函数定义的,这是一个系统程序

int main( )
{
 Member* memberChair = new Member("学生会主席", "张三", "男", "三", 2);      //初始化一棵树
 Member* memberSubChairOne = new Member("副主席", "赵一", "男", "三", 2);
 Member* memberSubChairTwo = new Member("副主席", "赵二", "男", "二", 2);
 Member* memberSubChairThree = new Member("副主席", "赵三", "女", "三", 3);
 Member* memberSubChairFour = new Member("秘书长", "赵四", "女", "一", 4);

 Member* member1 = new Member("文艺部长", "钱一", "女", "一", 5);
 Member* member2 = new Member("女生部长", "钱二", "女", "二", 4);
 Member* member3 = new Member("外联部长", "钱三", "男", "二", 5);

 Member* member4 = new Member("生卫部长", "孙一", "男", "三", 1);
 Member* member5 = new Member("体育部长", "孙二", "男", "一", 4);
 Member* member6 = new Member("社会实践部", "赵三", "男", "三", 3);

 Member* member7 = new Member("学习部长", "李一", "女", "二", 4);
 Member* member8 = new Member("生活部长", "李二", "女", "二", 6);

 Member* member9 = new Member("秘书部长", "周一", "女", "一", 3);
 Member* member10 = new Member("宣传部长", "周二", "男", "一", 4);

 Tree<Member> tree = Tree<Member>(memberChair);       //构造树的根结点

 tree.Insert(memberChair, memberSubChairOne);
 tree.Insert(memberChair, memberSubChairTwo);
 tree.Insert(memberChair, memberSubChairThree);
 tree.Insert(memberChair, memberSubChairFour);

 tree.Insert(memberSubChairOne, member1);
 tree.Insert(memberSubChairOne, member2);
 tree.Insert(memberSubChairOne, member3);

 tree.Insert(memberSubChairTwo, member4);
 tree.Insert(memberSubChairTwo, member5);
 tree.Insert(memberSubChairTwo, member6);

 tree.Insert(memberSubChairThree, member7);
 tree.Insert(memberSubChairThree, member8);

 tree.Insert(memberSubChairFour, member9);
 tree.Insert(memberSubChairFour, member10);       //初始化结束

轩辕追梦的主页 轩辕追梦 | 初学一级 | 园豆:130
提问于:2010-12-20 16:31
< >
分享
最佳答案
0

1、使用该函数再重构出另一个接口以供你说的其它程序进行调用;

2、或者,你也可以把这个tree 弄成全局变量以开发出一个接口供其它程序调用。。。

收获园豆:50
lzhdim | 小虾三级 |园豆:650 | 2010-12-20 18:02
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册