自己的stackoverflow的账号信息

展开阅读全文

stackoverflow的问题

12-20

我写一个定制的menu控件,控件里用了topmenu,submenu,menuitem这几个对象(类),每个类都代表一个层次的菜单。但是这里有一个stackoverflow的问题,总是得不到解决,希望那位大虾指点一下。部分程序如下:rnrnrnClass menurnrn rnrn //前面的没有问题,就不贴出来了rnrn public void AddTopmenu(Topmenu tm)rnrn private ArrayList topmenus=new ArrayList();rnrn rn rn if (tm !=null)rn this.topmenus.Add(tm);rn rn rn rn rnrnrnrnClass Topmenurnrn private ArrayList submenus=new ArrayList();rnrn rnpublic void AddSubmenu(Submenu sm)rn rn rn this.submenus.Add(sm);rn rn rnrnrnrnrnrnrnrnrnrnrnClass Submenurnrnrnrn //与这里无关,就省略了rnrnrnrnrnrn 结果在新建了一个webapplication之后,把这个控件放如form中后,我在page-load事件中写入下面的代码:rnrnprivate void Page_Load(object sender, System.EventArgs e)rn rn // 在此处放置用户代码以初始化页面rn Topmenu tm=new Topmenu("sina1","sina");rn Menu1.AddTopmenu(tm);rn Submenu sm=new Submenu("xix","hehe");rn rn rn tm.AddSubmenu(sm); //这一行就有问题了,出现stackoverflow的错误rnrn rnrn 这里我大致说一下我的menu的实现原理:rn 在每一个上层菜单对象里放入一个arraylist的成员来存储下一级的菜单,便于在输出的时候可以通过这个成员来输出下一级的菜单,但是这里就出现了这个overflow的问题,请大峡指点一二,谢谢了,如果方便,请留下您的联系方式,qq或者emailrn 论坛

搜索二叉树 stackoverflow

12-28

struct.hrn[code=c]rn#ifndef _struct_Hrn#define _struct_Hrntypedef struct Road_info rn unsigned short data_size; //数据大小 2bytern unsigned int LinkID; //道路编号 4bytern unsigned short road_size; //道路名称的尺寸 2byte rn //以下是NODE中的数据 4bytern unsigned int linkid; //番号 3-0rn unsigned int brunch; //分岔路 6-4rn unsigned int roadnameflag; //路标 7rn char *roadname; //道路名称 rnRoad_info;rnrn typedef struct Roadrn struct Road_info stRoadRec; //节点数据rn struct Road* next; //下一节点rnRoad;rnrn#endifrn[/code]rnrnrnMap_Tree.hrnrn[code=c]rn#includern#include "struct.h"rnrnrnrnrntypedef struct Map_Treern struct Map_Tree *left;rn struct Map_Tree *right;rn unsigned int data;rn*Map_tree;rnrnMap_tree CreatTree_byLinkId( Road *head, int position); //使用递归建立二叉树 Linkid部分rnMap_tree HalfSearch_byLinkId(Map_tree point, int findnode); //二叉树二分查找方式rnrnvoid show_byLinkd(Road *head);rn[/code]rnrnMap_Tree.crn[code=c]rn#include"Map_Tree.h"rnrnvoid show_byLinkd(Road *head)rnrn Map_tree root=NULL;rn Map_tree point=NULL;rn time_t a,b;rn char Run_time[80];rn unsigned int findnode;rn Road *temp;rnrnrn root=CreatTree_byLinkId(head,1);rn printf("请输入您所想要查询的LinkId:\n");rn scanf("%d",&findnode);rnrn a=time(NULL);rn strftime(Run_time,79,"%H:%M:%S",localtime(&a));rnrnrn point=HalfSearch_byLinkId(root,findnode);//用二分法查找二叉树rn if(point!=NULL)rn printf("#linkid=%d\n",head->stRoadRec.LinkID);rn printf("roadnameflag=%d\n",head->stRoadRec.roadnameflag);rn printf("brunch=%d\n",head->stRoadRec.brunch);rn printf("dispclass=%d\n",head->stRoadRec.linkid);rn printf("roadname=%s#\n",head->stRoadRec.roadname);rn temp->stRoadRec.LinkID=head->stRoadRec.LinkID;rn temp->stRoadRec.roadnameflag=head->stRoadRec.roadnameflag;rn temp->stRoadRec.brunch=head->stRoadRec.brunch;rn temp->stRoadRec.linkid=head->stRoadRec.linkid;rn temp->stRoadRec.roadname = head->stRoadRec.roadname;rn rn elsern printf("error:未找到结果!!\n");rnrn b=time(NULL);rn strftime(Run_time,79,"%H:%M:%S",localtime(&b));rnrn printf("本次查找用时%d 秒.\n",b-a); rnrnrnrnMap_tree CreatTree_byLinkId(Road *head, int position)rnrn Map_tree newnode; //声明新节点指针rnrn if(head->next==NULL) //递归的终止条件rn return NULL;rn elsern //建立新节点的内存空间rn newnode = (Map_tree) malloc(sizeof(Road));rnrn //建立节点内容rn newnode->data =head->stRoadRec.LinkID;rn //递归建立左子树rn newnode->left = CreatTree_byLinkId(head, 2*position);rn //递归建立右子树rn newnode->right = CreatTree_byLinkId(head, 2*position+1);rn return newnode; //返回树的位置rn rnrnrnMap_tree HalfSearch_byLinkId(Map_tree point, int findnode)rnrn while(point!=NULL)rn rn if(point->data==findnode)rn return point;//找到了该结点rn elsern if(point->data>findnode)rn point=point->left;rn elsern point=point->right;rn rn return NULL;rnrn[/code]rnrn在建立树的时候 stackoverflow了 一共有6万多条数据,链表rn现在不知道怎么解决,对 stack 不是很理解rn应该怎么办?? 论坛

类方法 stackoverflow

03-16

请问:rn我声明了一个类,其中有对数据库的添加,删除,修改等方法。rnrn在程序中,调用删除运行正常,调用添加和删除后,程序就死了,delphi的cpu占用率变高了。rnrn把这两个方法的实现部分注释掉,提示stack overflowrnrn类声明如下 //添加部分有2个子过程,rntypern //员工rn TEmployee = class (TObject)rn privatern Fid : Integer; //idrn FCode : string; // 编码rn FName : string; // 姓名rn FDepID : Integer; //部门idrn FMob : string; //移动电话rn FTel : string; //电话rn FEMail : string; //电子邮件rn FOicq : string; //Oicqrn FMSN : string; //MSNrn FBal : Real; //余额rn FRemark : string; //备注rn FDepName : string; //部门名称rn FQuery : TADOQuery;rn publicrn procedure Setid(const Val : Integer);rn procedure SetCode(const Val : string);rn procedure SetName(const Val : string);rn procedure SetDepID(const Val : Integer);rn procedure SetMob(const Val : string);rn procedure SetTel(const Val : string);rn procedure SetEmail(const Val : string);rn procedure SetOicq(const Val : string);rn procedure SetMSN(const Val : string);rn procedure SetBal(const Val : Real);rn procedure SetRemark(const Val : string);rn procedure SetDepName(const Val : string);rnrn property id : Integer read Fid write Setid;rn property Code : string read FCode write SetCode;rn property Name : string read FName write SetName;rn property DepID : Integer read FDepID write SetDepID;rn property Mob : string read FMob write SetMob;rn property Tel : string read FTel write SetTel;rn property EMail : string read FEMail write SetEMail;rn property Oicq : string read FOicq write SetOicq;rn property MSN : string read FMSN write SetMSN;rn property Bal : Real read FBal write SetBal;rn property Remark : string read FRemark write SetRemark;rn property DepName : string read FDepName write SetDepName;rnrn function Insert : Boolean;rn function Amend (id : Integer): Boolean;rn function Delete (id : Integer) : Boolean;rn procedure GetAllField(const xQuery : TADOQuery);rnrn constructor create; rn destructor destroy; override;rn end;rnrn//初始化rnconstructor TEmployee.create;rnbeginrn inherited create;rn FQuery := TADOQuery.Create(nil);rn FQuery.Connection := dm.con1;rnend;rnrn//修改rnfunction TEmployee.Amend(id : Integer): Boolean;rnbeginrn Result := False;rn if id >0 thenrn beginrn tryrn with FQuery dorn beginrn Close;rn SQL.Clear;rn SQL.Add('insert into dm_yg set ygxm=:ygxm,depid=:depid,stdh=:stdh,');rn SQL.Add('ggdh=:ggdh,dzyx=:dzyx,qq=:qq,msn=:msn,bz=:bz,zhje=:zhje where [id]=:id');rn Parameters.ParamByName('ygxm').Value := FName;rn Parameters.ParamByName('depid').Value := FDepID;rn Parameters.ParamByName('stdh').Value := FMob;rn Parameters.ParamByName('ggdh').Value := FTel;rn Parameters.ParamByName('dzyx').Value := FEMail;rn Parameters.ParamByName('qq').Value := FOicq;rn Parameters.ParamByName('msn').Value := FMSN;rn Parameters.ParamByName('bz').Value := FRemark;rn Parameters.ParamByName('zhje').Value := FBal;rn Parameters.ParamByName('id').Value := id;rn ExecSQL;rn end;rn Result := True;rn exceptrn Application.MessageBox('修改失败,请重新运行程序!', MB_Title, MB_OK +rn MB_ICONSTOP + MB_TOPMOST);rn Result:= False;rn end;rn end; rnend;rnrnrn//从数据库删除rnfunction TEmployee.Delete(id : Integer): Boolean;rnbeginrn Result := False;rn if ID > 0 thenrn beginrn tryrn with FQuery dorn beginrn if Application.MessageBox('是否删除该项数据?', MB_Title, MB_YESNO + MB_ICONQUESTION + MB_TOPMOST) = IDNO then Exit;rn with FQuery dorn beginrn Close;rn SQL.Clear;rn SQL.Add('select * from dm_yg where [id]=:id');rn Parameters.ParamByName('id').Value := ID;rn Open;rnrn if RecordCount > 0 thenrn beginrn if Application.MessageBox('该数据项正被其他数据使用,是否删除?', MB_Title, MB_YESNO + MB_ICONWARNING + MB_TOPMOST) = IDNO then Exit;rn Close;rn SQL.Clear;rn SQL.Add('delete from dm_yg where [id]=:id');rn Parameters.ParamByName('id').Value := ID;rn ExecSQL;rn end;rn end;rn end;rn Result := True;rn exceptrn Application.MessageBox('无法删除,请重新运行程序!', MB_Title, MB_OK +rn MB_ICONSTOP + MB_TOPMOST);rn Result:=False;rn end;rn end;rnend;rnrn//析构rndestructor TEmployee.destroy;rnbeginrn rn FQuery.Close;rn FreeAndNil(FQuery);rn inherited;rnend; rnrn 论坛

没有更多推荐了,返回首页