求教:注释一下DElETE函数

#include
#include
using namespace std;
struct item
{
char name[12];
char telnum[8];
item *next;
};
class TeleBook
{
private:
item *tbook;
int number;
public:
TeleBook()
{
tbook=NULL;
number=0;
}
void Insert();
void Delete();
void Print();
};
void TeleBook::Insert()
{
item *p;
p=new item;
if(!p)
return;
cout<<"Input name and telenumber:";
cin>>p->name>>p->telnum;
p->next=tbook;
tbook=p;//指向下一个位置;
number++;
}
void TeleBook::Delete()
{
char ch[12];
item *p,*q;
p=tbook;
cout<<"Input the name to be delete:";
cin>>ch;
while(p)
{
if(strcmp(p->name,ch)==0)
{
break;
}
q=p;
p=p->next;
}
if(p==NULL)
{
cout<<"Not found the name!"< return;
}
if(p==tbook)
{
tbook=p->next;
}
else
{
q->next=p->next;
}
number--;
cout<name<<"is deleted!"< delete p;
return;
}
void TeleBook::Print()
{
item *p;
p=tbook;
cout while(p)
{
coutname<<':'<telnum< p=p->next;
}
return;
}
int main()
{
int ch;
TeleBook myfriend;
ch=1;
cout<<"1.输入,2.删除,3.打印清单,other-退出\n";
cout<<"Please choose!";
cin>>ch;
switch(ch)
{
case 1:
myfriend.Insert();
break;
case 2:
myfriend.Delete();
break;
case 3:
myfriend.Print();
break;
}
return 0;
}

c++

1个回答

Delete 中有些地方可能导致崩溃,如下:

void TeleBook::Delete()
{
    char ch[12];
    item *p,*q;
    //tbook 是个链表,p 指向表头
    p=tbook;
    cout<<"Input the name to be delete:";
    cin>>ch;
    while(p)
    {
        //如果元素p中name 属性 == ch 则跳出
        if(strcmp(p->name,ch)==0)
        {
            break;
        }
        q=p;
        //访问下一个链表元素
        p=p->next;
    }
    //没有找到
    if(p==NULL)
    {
        cout<<"Not found the name!"< return;
        //这里没有找到应该直接返回
        //return ;
    }
    //如果找到的p和头元素相同
    if(p==tbook)
    {
        //删除头部的元素,修改头指针,可能存在问题,如果tbook=NULL,p=NULL,这里则崩溃
        tbook=p->next;
    }
    else
    {
        //如果没有扎到,走到这里则崩溃
        //将p从链表中剔除
        q->next=p->next;
    }
    //个数减一
    number--;
    cout<name<<"is deleted!"< delete p;
    return;
}

justin_bkdrong
枫舞的季节 回复znevegiveup1: 可以的,因为这个tbook 是链表的头指针,类型和p一样。tbook 的意义是一个链表,表现是一个头指针
大约 2 年之前 回复
znevegiveup1
wnevegiveup 大神指教一下:Insert()中p->=tbook;tbook=p什么意思?链表可以赋值给指针吗?
大约 2 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
求教delete和delete[]
近日,小弟发现程序运行时内从不断在增加,后发现new申请空间没有释放,我申请的是rn二维数组,程序是:rnBYTE **Array;rnArray=new BYTE*[常量];rnfor(int i=0;i
求教一下函数问题
#include rn#include rnrnrnrnstruct studentrn rn char name[100];rn float score;rn;rnrnint main(void)rnrn int len;rn int i, j;rn struct student * parr;rn struct student t;rn rn rn printf("请输入学生人数 len = ");rn scanf("%d", &len);rn printf("\n");rn rn parr = (struct student *)malloc(len * sizeof(struct student));rn rn for (i=0; i parr[j+1].score)rn rn t = parr[j];rn parr[j] = parr[j+1];rn parr[j+1] = t;rn rn rn rn rn return 0;rnrnrnrnrnrnrn这段要写成函数应该发送哪两个参数,最好能写详细点给我参考下rn for (i=0; i parr[j+1].score)rn rn t = parr[j];rn parr[j] = parr[j+1];rn parr[j+1] = t;rn rn
求教一下 memset函数的使用
int a[100];rnmemset(a, 0, sizeof(a);这样清零是正确的 不过memset(a, 1, sizeof(a));就是错误的了 大概看了一下百度说因为是按位运算的原因rn我自己又试了一个这样的memset(a, -1, sizeof(a));然后我把结果输出来 是-1!!!!我想问一下要是我想把a数组全赋值为-1这样用可以吗?rn
delete函数
Drools规则引擎是一种嵌套在应用程序中的组件,它实现了将业务规则从应用程序代码中分离出来。本次课程的主要内容分为以下几个方面:rn1.规则引擎、 Drools规则引擎简介rn2.Drools规则引擎各类基础知识点讲解,如kmodule、no-loop、salience等rn3.各类基础函数以及决策表,动态加载规则rn4.实战式教学以及课程总结
DELETE函数
_RecordsetPtr只能指向的delete函数怎么用的,举个例子,还有它的参数是怎么定义,初始化的,,跟这个函数有关联的前前后后,代码贴的详细点,,,感激不尽,,,
求教执行DELETE
在CDaoRecordset继承类中添加一个语句rnvoid CCheciSet::DeleteCheci(const CString &strCheci)rnrn //删除rn CString strToExecute="DELETE FROM [checi] WHERE [checi].[checi]='";rn strToExecute+=strCheci;rn strToExecute+="';";rn char str[255];rn tryrn rn m_pDatabase->Execute(strToExecute);rn rn catch(CDaoException *e)rn rn e->GetErrorMessage(str,255);rn e->Delete();rn rn catch(CMemoryException *e)rn rn e->GetErrorMessage(str,255);rn e->Delete();rn rnrn为什么执行到m_pDatabase->Execute(strToExecute);就弹出Unhandle Exception的错误?rn我跟踪了strToExecute为DELETE FROM [checi] WHERE [checi].[checi]='T1';rn请问这是怎么回事,DBMS是ACCESS97谢谢!
这几个函数能不能帮我注释一下
<%rnFunction strFilter(str,n)rn str = Trim(str)rn If Vartype(str) <> vbNull thenrn str = Replace(str, "'", "")rn str = Replace(str, """", "")rn str = Replace(str, "&", "")rn str = Replace(str, "|", "")rn str = Server.HTMLEncode(str)rn str = Replace(str,CHR(13),"")rn str = Replace(str,CHR(10),"")rn End ifrn strFilter = GetWord(str,n,"")rnEnd FunctionrnrnFunction GetLength(strChinese1)rn Dim strWord, ascWord, lenTotalrn strChinese1 = Trim(strChinese1)rnrn If strChinese1 = "" or Vartype(strChinese1) = vbNull thenrn GetLength = 0rn Exit Functionrn End Ifrnrn lenTotal = 0 rn For GetLengthi=1 to Len(strChinese1)rn strWord = Mid(strChinese1, GetLengthi, 1)rn ascWord = Asc(strWord)rn If ascWord < 0 or ascWord > 127 thenrn lenTotal = lenTotal + 2rn Elseif ascWord = 63 And strWord <> "?" thenrn lenTotal = lenTotal + 2rn Elseif ascWord = 44 And strWord <> "," thenrn lenTotal = lenTotal + 2rn Elseif ascWord = 33 And strWord <> "!" thenrn lenTotal = lenTotal + 2rn Elsern lenTotal = lenTotal + 1rn End Ifrn Nextrnrn GetLength = lenTotalrnEnd FunctionrnrnFunction GetWord(strChinese2, lenMaxWord, strTail)rn strChinese2 = Trim(strChinese2)rn lenMaxWord = CCur(lenMaxWord)rnrn If strChinese2 = "" or Vartype(strChinese2) = vbNull or CLng(lenMaxWord) <= 0 thenrn GetWord = ""rn Exit Functionrn End Ifrnrn Dim OverFlow, strTestrn OverFlow = Falsern strTest = " "rnrn If GetLength(strChinese2) > lenMaxWord then OverFlow = Truernrn If OverFlow = True thenrn Dim lenWord, RetString, strWord, ascWordrn lenWord = 0rn RetString = ""rn For GetWordi=1 to Len(strChinese2)rn strWord = Mid(strChinese2, GetWordi, 1)rn ascWord = Asc(strWord)rn If ascWord < 0 or ascWord > 127 thenrn lenWord = lenWord + 2rn Elseif ascWord = 63 And strWord <> "?" thenrn lenWord = lenWord + 2rn Elseif ascWord = 44 And strWord <> "," thenrn lenWord = lenWord + 2rn Elseif ascWord = 33 And strWord <> "!" thenrn lenWord = lenWord + 2rn Elsern lenWord = lenWord + 1rn End Ifrn If lenWord <= (lenMaxWord - Len(strTail)) thenrn RetString = RetString + strWordrn Elsern GetWord = RetString + strTailrn Exit Forrn End Ifrn Nextrn Elsern GetWord = strChinese2rn End IfrnEnd Functionrnrnfunction checkStr(str)rn if isnull(str) thenrn checkStr = ""rn exit function rn end ifrn checkStr=replace(str,"'","''")rnend functionrnrnFunction ReplaceText(strT,patT,repT)rn Set regEx = New RegExprn regEx.Global = Truern regEx.IgnoreCase = Truern regEx.Pattern = patTrn Reptext = regEx.Replace(strT,repT)rn Set regEx = nothingrn ReplaceText = ReptextrnEnd FunctionrnrnFunction DoubleNum(Num)rn If Num > 9 then rn DoubleNum = Num rn Else rn DoubleNum = "0" & Numrn End IfrnEnd FunctionrnFunction CreateOption(tableName, fieldName, fieldValue, defaultValue)rn Dim selectedValuern selectedValue = ""rn If defaultValue <> "" Thenrn selectedValue = defaultValuern End Ifrn set rsOptions = Server.CreateObject("ADODB.Recordset")rn Dim sqlCreateOptionrn sqlCreateOption = "SELECT " & fieldValue & "," & fieldName & " FROM " & tableNamern rsOptions.Open sqlCreateOption, conn,1,1rn Dim retValuern retValue = ""rn Do While not rsOptions.EOFrn retValue = retValue & "" & rsOptions.Fields(fieldName).Value & ""& vbcrlfrn rsOptions.MoveNext()rn If rsOptions.EOF Thenrn Exit Dorn End Ifrn Looprn rsOptions.Close()rn set rsOptions = Nothingrn CreateOption = retValuernEnd Functionrn'出现提示窗rnFunction MsgBox(error,n)rn Set rs = nothingrn Set conn = nothingrnrn Copyright = "\n\n"rnrn Response.write"" & vbcrlf & _rn "" & vbcrlf & _rn " 提示" & vbcrlf & _rn " " & vbcrlf & _rn " " & vbcrlf & _rn " " & vbcrlf & _rn "" & vbcrlf & _rn " " & vbcrlf & _rn "" & vbcrlf & _rn " " & vbcrlf & _rn "" & vbcrlf & _rn ""rn Response.endrnEnd Functionrn%>
求教一delete语句
我是通过比较两个表的纪录,然后保存到第三个表中的操作,具体操作看http://topic.csdn.net/u/20091012/10/34b18e8a-bd0c-4c73-ab28-3f662b4cb1a7.html 十一楼的方法rn由于这里面是通过full join操作后rn比如 rn对于 a表中的rn物料编码 部门 rn1001 钢结构分厂rn1001 木配件rnb表中的rn1001 钢结构分厂rn1001 木配件rn导入后的结果是rn物料编码_a 部门_a 物料编码_b 部门_brn1001 钢结构分厂 1001 钢结构分厂rn1001 钢结构分厂 1001 木配件rn1001 木配件 1001 钢结构分厂rn1001 木配件 1001 木配件rn如果他们之间进行比较的话,其实只是比较同一物料编码下的部门相同的纪录进行比较rn按照上面的要求的话 rn其实应该是这样的一个比较结果rn物料编码_a 部门_a 物料编码_b 部门_brn1001 钢结构分厂 1001 钢结构分厂rn1001 木配件 1001 木配件 rnrn所以我想使用 这样的思路rndelete from table where 部门_a<>部门_b and (count(材料编码_a)>1 or count(材料编码_b)>1)rn但是执行起来是不对的rn这样去删除不应该比较的那些情况rn请问我的这个delete方法该如何改变成为正确的呢?rn
求教delete问题
int main(int argc, char* argv[])rnrn int i = 10;rn char* pch = new char;rn itoa(i,pch,10);rn cout << pch << endl;rn delete pch;//这个delte会导致异常,不太明白,高人在哪里?rn pch = 0;rnrn return 0;rn
数据库delete问题,求教
Dim delCmd As String = "delete from textss where ID =" & 0rnrnID是int型,rn错误提示rn未将对象引用设置到对象的实例
確認一下delete和free
free是否可以刪除一切由malloc和new出來的內存?rndelete 是否有時不能刪除由malloc函數生成的內存?
诚心求教注释!!!!
/*读取自带汉字库的汉字*/rnvoid Put_Lib_Hz(int x,int y,int w,int color,unsigned char *s)rn rn FILE *Lib;rn unsigned int *HZQW;rn unsigned char *HZDZ;rn int k,Number;rn long i;rn unsigned char *cw;rn char c[2];rn unsigned long int qu,wei,qw,Len;rn if((Lib=fopen(HzLib,"rb"))==NULL)rn closegraph();rn printf("\007Can't find %s !\n",HzLib);rn exit(0);rn setcolor(color);rn settextstyle(0,0,1);rn fseek(Lib,0,2);rn Len=ftell(Lib);rn Number=Len/34;rn fseek(Lib,0,0);rn if((HZQW=(unsigned int *)malloc(Number*2))==NULL)rn closegraph();rn exit(0);rn if((HZDZ=(unsigned char *)malloc(Number*32))==NULL)rn free(HZQW);rn closegraph();rn exit(0);rn fread(HZQW,Number,2,Lib);rn fread(HZDZ,Number*32,1,Lib);rn fclose(Lib);rnrn for(k=0;s[k]!='\0';k+=2)rn if((s[k]&0x80)!=0)rn qu=s[k]-161; //区号rn wei=s[k+1]-161; //位号rn qw=qu*100+wei;rn for(i=0;i
VB 求教 方法注释
我想使用这个注释,但是'''+回车并不能获取到,是要设置什么引用吗? rn ''' rn ''' rn ''' rn ''' rn ''' rn '''
关于new delete函数
楼主是小白[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/49.gif][/img]想知道一下代码哪里有问题rn#include"stdio.h"rn#include"string.h"rnrnint main(int argc, char* argv[])rn char *a=new char;rn gets(a);rn printf("%s\n",a);rn delete[](a);rnrn return 0;rnrn错误对话框截屏:[img=https://img-bbs.csdn.net/upload/201312/02/1385978430_566499.jpg][/img]rn如果不写结尾的delete,执行就是成功的[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/15.gif][/img]。rn
一个delete char 的函数
#includernvoid * delch(char *p,char ch) rnrn int i=0;rn char *dest=(char*)malloc(sizeof(char)*strlen(p));rn while (*p!='\0')rn rn if (*p==ch)rn printf("cccc");rn p++;rn rn elsern *dest++=*p++;rn rn rn strcpy(p,dest); // ********rn free(p); //************rn rn rn rnint main()rnrn char *p="12345";rn delch(p,'3');rn while (*p!='\0')rn printf("%c",*p++);rnrn~ 有段错误 !
简单链表类的DELETE函数
这是头文件:n#include nusing namespace std;ntemplatenclass KNOTEnnpublic:n A data;n KNOTE * next;n KNOTE(A data,KNOTE * next);n virtual ~KNOTE();n;ntemplatenKNOTE::KNOTE(A data,KNOTE * next)nn this->data=data;n this->next=next;nntemplatenKNOTE::~KNOTE()nn delete next;nntemplatenclass LInnprivate:n KNOTE * headp;npublic:n LI();n ~LI();n KNOTE * GETP(int pos);n int length();n bool CLEAR();n bool SETV(int pos,A v);n bool GETV(int pos,A & v);n bool INSERT(int pos,A v);n bool DELETE(int pos,A & v);n;ntemplatenLI::LI()nn headp=new KNOTE(0,NULL);n ntemplatenLI::~LI()nn A temp;n while(length()>0)n n DELETE(1,temp);n nntemplatenint LI::length()nn int len=0;n KNOTE * tempp=headp->next;n while(tempp!=NULL)n n len++;n tempp=tempp->next;n n return len;nntemplatenKNOTE * LI::GETP(int pos)nn KNOTE * tempp=headp;n if(pos<0||pos>length())n return NULL;n elsen n int cur=0;n while(cur!=pos)n n tempp=tempp->next;n cur++;n n return tempp;n nntemplatenbool LI::SETV(int pos,A v)nn KNOTE * tempp;n if(pos<1||pos>length())n return false;n elsen n tempp=GETP(pos);n tempp->data=v;n return true;n nntemplatenbool LI::GETV(int pos, A & v)nn KNOTE * tempp;n if(pos<1||pos>length())n return false;n elsen n tempp=GETP(pos);n v=tempp->data;n return true;n nntemplatenbool LI::CLEAR()nn KNOTE * tempp1=headp->next;n KNOTE * tempp2;n while(tempp1!=NULL)n n tempp2=tempp1->next;n delete temp1;n temp1=temp2;n nntemplatenbool LI::INSERT(int pos,A v)nn if(pos<1||pos>length()+1)n return false;n elsen n KNOTE * pre_p;n KNOTE * new_p;n pre_p=GETP(pos-1);n new_p=new KNOTE(v,pre_p->next);n pre_p->next=new_p;n return true;n nntemplatenbool LI::DELETE(int pos,A &v)nn if(pos<1||pos>length())n return false ;n elsen n KNOTE * pre_p;n KNOTE * temp_p;n pre_p=GETP(pos-1);n //KNOTE * pre_p1=headp->next;n temp_p=pre_p->next;n pre_p->next=temp_p->next;n v=temp_p->data;n //KNOTE * pre_p2=headp->next;n delete temp_p;n //KNOTE * pre_p3=headp->next;n return true;n nnnnnn n以下是主函数n#include "head.h"nint main()nn LI aa;n int v;n for(int i=1;i<=10;i++)n n aa.INSERT(1,i+2);n n for(int i=1;i<=10;i++)n n aa.GETV(i,v);n cout<next;已经对头指针指针域改变,但deletetemp_p后还是会报错?求大神回答
有关delete函数的问题?
设计了以下代码:rnvarrninput,output,str:string;rnbeginrninput:=copy(str,1,6);rndelete(str,1,6);rnoutput:=copy(str,1,6);rnrnstr 变量的值是从文本文件(没设成自动换行)load来的,其内容举例如下:rn123456rn789111rn122496rn共有n行,每行的字节数都相同(这里举例为6个)。rn我想问执行delete(str,1,6);后是否会得到一行空行?这样output的值为空值?如果是用什么办法可以将第一行的空行去掉,让output能取得第2的值(就是让output=‘789111’)。rn因为是有n行,n为不知数,所以不能用output:=(str,7,6);这种方法取得第2行,以及第3,4.....行。rn请高手告诉我解决的办法
delete 函数释放出错
代码如下,出错的地方我加注释rn#include "stdafx.h"rnchar *mystringget(char *p,int i)rnchar *pp;rnpp=new char [100];rnstrcpy(pp,p);rnint k=strlen(pp);rnpp=(pp+k-i);rnif (i
delete()函数的疑问
一般new跟delete是配对使用的。查了相关资料,得到的结果是rnnew + 类型 配对 delete + 指针名;rnnew + 类型[n] 配对 delete[] + 指针名;rn即rnint *p = new int;//释放时用 delete p,p=NULL;rnint *p = new int[10];//释放时用 delete[] p,p=NULL;rn上面的我已经弄明白。rnrn现在我不明白的是,在我的代码中,我是这样用的rnrn//申请内存rnint *p = new int[10000];//释放时用 delete(p) ,p=NULL;rnrn...//对p进行操作rnrn//操作完成后释放rndelete(p);//原来不知道正确的做法要用delete[] p;rnp=NULL;rnrn程序运行时这段代码不断被调用,通过任务管理器查看,内存能够被释放,即内存的使用很稳定。rn现在想知道delete(p)与delete[] p;到底有什么区别?rn使用delete(p)会不会存在什么风险?rn我猜想delete()应该是c函数,而delete则是c++关键字,但是查找MSDN与在网上都找不到delete()的介绍。
_RecordsetPtr Delete函数
ADODB::_RecordsetPtr pRecordSet = NULL;rn....rnpRecordSet->Delete(adAffectCurrent);rnpRecordSet->Update();rnrn系统提示:error C2065: 'adAffectCurrent' : undeclared identifierrn
求教一下这个函数的详细解释
如题:rnpublic static String ipYuMsk(InetAddress ip)rn rn rn byte[] b=ip.getAddress();rn long l= b[0] < <24L & 0xff000000L ¦rn b[1] < <16L & 0xff0000L ¦rn b[2] < <8L & 0xff00L ¦rn b[3] < <0L & 0xffL ;rn rn return Integer.toBinaryString((int)l);rn
Delete函数格式?
-
函数外delete
#include "stdafx.h" #include &lt;windows.h&gt; #include&lt;iostream&gt; namespace newSpace { char *str = new char[20]; void deleteStr() // 其实没有什么用 { delete[] str; } } char...
数据删除delete函数
不管把是数据整理到模型训练你的模型,还是做漂亮的各种可视化图都需要整理好数据,要美地传数据,numpy是python数据处理的核心基础,几乎没有一个python数据分析工具不用numpy的。比如pandas, sickit,甚至各种深度学习框架比如tensorflow都离不开numpy。n咨询讨论QQ群:633455803 咨询微信:eConnection
关于new,delete的问题,求教
[size=16px][b] m_ItemList itemlist;rn for (size_t i =0;&i < len;i++)rn rn Item *item = new Item;rn item->name = "xljOPC1";rn itemlist.AddTail(item);rn rn driver->ReadValue(itemlist);[/b][/size]rn如果我在for循环里delete,那么后续的itemlist就不能使用了,请问这种情况我该在哪里delete呢?rnm_ItemList 是对象列表typedef CTypedPtrList m_ItemList;
小弟求教关于DELETE的问题
我遇到一个情况,就是当表中大部分数据的时候,大概有几十万到一百多万吧,rn用delete from 表 where 删除的时候 数据库日志会很大~~~求解决方法
关于new和delete的问题求教
[code=C/C++]#includernusing namespace std;rnclass U_Ptrrn friend class HasPtr;rn int *ip;rn size_t use;rn U_Ptr(int*p):ip(p),use(1) rn ~U_Ptr()rn rn cout<<"delete U_Ptr"<use;rn cout<use<use==0) rn rn delete ptr; rn rn cout<<"delete ptr "<use<use;rn if(--ptr->use==0)rn delete ptr;rn ptr=rhs.ptr;rn val=rhs.val;rn return *this;rnrnrnint main()rnrnrn int obj;rn HasPtr p1(&obj,42);rn std::cout<<"********************************"<
高分求教有关delete的问题!
CNodeLine* pNodeLine = NULL;rn NodeList.MoveCurrentToTop();rn for (int i = 0; i < ScriptList.GetCounter();)rn rn rn pNodeLine = NodeList.GetCurrentData();rn rn if (pNodeLine )rn rn delete pNodeLine ;rn pNodeLine =NULL;rn rn NodeList.DeleteCurrentNodeEx();rn rn rnNodeList 是一个处理node的模板类rnCNodeLine 一个类,包含2个char* 和2个intrnNodeList.DeleteCurrentNodeEx();这个函数是将节点其他数据清零,不清除压入节点的类实例。rnrn每次用NodeList.AddNode 把很多CNodeLine 的实例压入到NodeList rn第二次用的时候先将节点删除,然后重新压入rnrn在删除的时候,delete pNodeLine 不定时的出错,我查过了,删除之前pNodeLine 都是有效指针,并且整个程序只有这一个地方delete pNodeLine ,其他地方都没有类似操作!程序也没有其他线程rnrn更奇怪的是,如果在删除之前加一个sleep(20),出错的几率会小很多!!sleep越久,出错的几率越小rn请各位大大帮我分析一下出错的原因,高分相送!(如果100分不够,可以另送)rn答者皆有分送,谢谢大家
求教关于重载delete[]的问题
虽然是老生常谈的问题,但还是有些地方搞不懂rn不知道我理解的对不对?请多多指教rnrn做试验发现:(vs2005)rn我在重载delete[]操作符的时候,如果给定了第二个参数size_trn那么传递进来的值竟然是sizeof(TYPE),而不是对象数组的长度!!rnrn过程是这样的:rnrnclass Arnrnpublic:rn A()cout<<"co"<
帮我注释一下吧
rnrn 帮我把下面这段代码注释一吧 谢谢大家了 rnrnusing System;rnusing System.Data;rnusing System.Configuration;rnusing System.Web;rnusing System.Web.Security;rnusing System.Web.UI;rnusing System.Web.UI.WebControls;rnusing System.Web.UI.WebControls.WebParts;rnusing System.Web.UI.HtmlControls;rnusing System.Data.SqlClient;rn//该源码首发自www.51aspx.com(51aspx.com)rnrn/// rn/// SqlHelper 的摘要说明rn/// rnpublic class SqlHelperrnrn private static readonly string strConn = ConfigurationManager.ConnectionStrings["TangCompanyConn"].ConnectionString;rn private static readonly string strName = ConfigurationManager.AppSettings["userName"].ToString();rn private static readonly string strPass = ConfigurationManager.AppSettings["userPass"].ToString();rn public SqlHelper()rn rn //rn // TODO: 在此处添加构造函数逻辑rn //rn rn public static SqlDataReader ExcuteRead(string nText, CommandType nType, SqlParameter[] paras) rnrn SqlConnection conn = new SqlConnection(strConn);rn SqlCommand cmd = new SqlCommand();rn tryrn rn PrepareCommand(conn, cmd, null, nType, nText, paras);rn SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);rn cmd.Parameters.Clear();rn return dr;rn rn rn catch(SqlException ex)rnrn throw new Exception(ex.Message, ex);rn rn rn rn rn public static int ExcuteNonQurey(string nText, CommandType nType, SqlParameter[] paras) rnrn SqlCommand cmd = new SqlCommand();rn using (SqlConnection conn = new SqlConnection(strConn)) rnrn PrepareCommand(conn, cmd, null, nType, nText, paras);rn int rows = cmd.ExecuteNonQuery();rn cmd.Parameters.Clear();rn return rows;rn rn rn rn rn public static object ExcuteSclare(string nText, CommandType nType, SqlParameter[] paras) rnrn SqlCommand cmd = new SqlCommand();rn using (SqlConnection conn = new SqlConnection(strConn)) rnrn PrepareCommand(conn, cmd, null, nType, nText, paras);rn object obj = cmd.ExecuteScalar();rn cmd.Parameters.Clear();rn return obj;rn rn rn rn public static DataSet ExcuteReadApdater(string nText, CommandType nType, SqlParameter[] paras) rnrn SqlConnection con = new SqlConnection(strConn);rn SqlCommand cmd = new SqlCommand();rn DataSet ds = new DataSet();rn tryrn rn PrepareCommand(con, cmd, null, nType, nText, paras);rn SqlDataAdapter sqlAdapter = new SqlDataAdapter(cmd);rn sqlAdapter.Fill(ds);rn cmd.Parameters.Clear();rn return ds;rnrn rn catch (SqlException ex) rnrn throw new Exception(ex.Message, ex);rn rn rn rn public static void PrepareCommand(SqlConnection con, SqlCommand cmd, SqlTransaction trans, CommandType nType, string nText, SqlParameter[] paras) rnrn if (con.State != ConnectionState.Open)rn con.Open();rn cmd.Connection = con;rn cmd.CommandText = nText;rn if (trans != null) rnrn cmd.Transaction = trans; rn rn cmd.CommandType = nType;rn if (paras != null) rnrn foreach (SqlParameter para in paras) rnrn cmd.Parameters.Add(para); rn rn rn rn rnrnrn
请注释一下
program Project2;rnrn$APPTYPE CONSOLErnrnusesrn SysUtils;rntypern TStuRec=recordrn stu_no:integer;rn stu_name:string;rn stu_credit:integer;rn case optional_tagfield:required_ordinal_type of//注释arn 1:variantname1:varianttype1;//注释brn 2,3:variantname2:varianttype2;//注释crn end;rnvarrn ZhangMing,Wanghua:TStudRec;rnbeginrn ZhangMing.stu_no:=55;rn ZhangMing.stu_name:='ZhangMing'; TODO -oUser -cConsole Main : Insert code here rnend.
帮我注释一下
帮我把下面的这段js 代码注释一下吧 rnrnfunction globals_checkSession(type, flag) //rn $.ajax(rn rn url:"../actions/loginAction.aspx",rn type:"POST", rn dataType:"xml",rn timeout:20000,rn data:"action=4",rn error: function()alert("服务器连接超时,请稍候重试!"); ,rn success:function(res)rn if($(res).find("clientInfo").attr("valid") == "0")rn $(res).find("clientInfo").children().each(function()rn if($("#txt_client_name").length == 0)rn return;rn rn elsern $("#txt_" + $(this)[0].tagName).val($(this).text());rn if($("#txt_" + $(this)[0].tagName).length > 0)$("#txt_" + $(this)[0].tagName).attr("readOnly", true);rn rn )rn rn if(type == "Q") //qsrn qs_loadInfo(flag);rn rn rn if(type == "J") //ysrn ys_loadInfo(flag);rn rn rn if(type == "YSDJ")rn ysdj_load();rn rn rn if(type == "YSFPB")rn ys_fpbload();rn rn rn if(type == "LSYSZBSQ")rn ys_lszbload();rn rn rn if(type == "YYCGZBYYJH")rn ys_yycgzbload();rn rn rn if(type == "U")rn $("#top_uname").text($(res).find("client_name").text());rn rn rn elsern window.parent.window.location.href = "../sessionError.htm";rn rn rn );rnrnrn//functionsrnrn//qs beginrnrnrnrnrnrnfunction delQSSQ_SJGCRow()rn $(event.srcElement).parent().parent().remove();rnrnrnfunction btnQSSQ_PostClick (state) rn var xmlParam = "";rn rn //checkrn if($("#txt_QSQX_B").val() == "" || $("#txt_QSQX_E").val() == "")rn alert("请输入申请取水期限");rn return;rn rn rn var b = false;rn //1 beginrn $("#QSXK_ADD_1").find("input").each(function()rn if(this.id == "txt_NSQQSZL") rn b = true; rn rn rn if(b)rn if(this.type.toLowerCase() == "radio")rn if( $(this).attr("checked"))rn xmlParam += "&table_qssq_" + this.id.replace(/txt_/g, "") + "=" + this.value;rn rn rn elsern if(this.id == "txt_QSFS_PT") alert('text'); rn xmlParam += "&table_qssq_" + this.id.replace(/txt_/g, "") + "=" + $(this).val();rn rn rn );rn rn $("#QSXK_ADD_1").find("textarea").each(function()rn xmlParam += "&table_qssq_" + this.id.replace(/txt_/g, "") + "=" + $(this).text();rn );rn rn //1endrn rn //2beginrn rn $("#QSBD_ADD_1").find("input").each(function()rn if(this.type.toLowerCase() == "checkbox")rn if( $(this).attr("checked"))rn xmlParam += "&table_qsbd_" + this.id.replace(/txt_/g, "") + "=" + this.value;rn rn rn elsern xmlParam += "&table_qsbd_" + this.id.replace(/txt_/g, "") + "=" + $(this).val();rn rn );rn rn //2endrn rn //3beginrn rn var tmpStr = "&table_sjgc_dbg=";rn rn $("#SJGC_ADD .dbgDetail").each(function()rn tmpStr += "";rn $(this).children().each(function()rn if($(this).children().length > 0 && $(this).children()[0].tagName.toLowerCase() == "input")rn tmpStr += $(this).children().attr("id") + "~" + $(this).children().val() + ",";rn rn );rn tmpStr+="|";rn );rn rn $("#SJGC_ADD").find("textarea").each(function()rn xmlParam += "&table_qsex_" + this.id.replace(/txt_/g, "") + "=" + $(this).val();rn );rn rn xmlParam += tmpStr;rn rn //3endrn rn //4 beginrn rn tmpStr = "&table_tsgc_dbg=";rn rn $("#TSGC_ADD .dbgDetail").each(function()rn tmpStr += "";rn $(this).children().each(function()rn if($(this).children().length > 0 && $(this).children()[0].tagName.toLowerCase() == "input")rn tmpStr += $(this).children().attr("id") + "~" + $(this).children().val() + ",";rn rn );rn tmpStr+="|";rn );rn rn $("#TSGC_ADD").find("textarea").each(function()rn xmlParam += "&table_qsex_" + this.id.replace(/txt_/g, "") + "=" + $(this).val();rn );rn rn xmlParam += tmpStr; rn rn //4 endrn rn //5 beginrn rn tmpStr = "&table_ysgc_dbg=";rn rn $("#YSGC_ADD .dbgDetail").each(function()rn tmpStr += "";rn $(this).children().each(function()rn if($(this).children().length > 0 && $(this).children()[0].tagName.toLowerCase() == "input")rn tmpStr += $(this).children().attr("id") + "~" + $(this).children().val() + ",";rn rn );rn tmpStr+="|";rn );rn rn $("#YSGC_ADD").find("textarea").each(function()rn xmlParam += "&table_qsex_" + this.id.replace(/txt_/g, "") + "=" + $(this).val();rn );rn rn xmlParam += tmpStr; rn rn //5 endrn rn //6 beginrn tmpStr = "&table_xsgc_sdz_dbg=";rn rn $("#XSGC_SDZ_ADD .dbgDetail").each(function()rn tmpStr += "";rn $(this).children().each(function()rn if($(this).children().length > 0 && $(this).children()[0].tagName.toLowerCase() == "input")rn tmpStr += $(this).children().attr("id") + "~" + $(this).children().val() + ",";rn rn );rn tmpStr+="|";rn );rn rn $("#XSGC_SDZ_ADD").find("textarea").each(function()rn xmlParam += "&table_qsex_" + this.id.replace(/txt_/g, "") + "=" + $(this).val();rn );rn rn xmlParam += tmpStr; rn //6 endrn rn //7 beginrn tmpStr = "&table_xsgc_psdz_dbg=";rn rn $("#XSGC_PS_ADD .dbgDetail").each(function()rn tmpStr += "";rn $(this).children().each(function()rn if($(this).children().length > 0 && $(this).children()[0].tagName.toLowerCase() == "input")rn tmpStr += $(this).children().attr("id") + "~" + $(this).children().val() + ",";rn rn );rn tmpStr+="|";rn );rn rn $("#XSGC_PS_ADD").find("textarea").each(function()rn xmlParam += "&table_qsex_" + this.id.replace(/txt_/g, "") + "=" + $(this).val();rn );rn rn xmlParam += tmpStr; rn //7 endrn rn //8beginrn rn $("#SZYLZ_ADD_1").find("input").each(function()rn xmlParam += "&table_szylz_" + this.id.replace(/txt_/g, "") + "=" + $(this).val();rn );rn rn $("#SZYLZ_ADD_1").find("textarea").each(function()rn xmlParam += "&table_szylz_" + this.id.replace(/txt_/g, "") + "=" + $(this).val();rn );rn rn //8endrn rn $("#btnQSSQ_PostLoad").ajaxStart(function()$(this).show(); );rn $("#btnQSSQ_Post").ajaxStart(function()$(this).attr("disabled", true); );rn $("#btnQSSQ_Back").ajaxStart(function()$(this).attr("disabled", true); );rn rn $("#btnQSSQ_PostLoad").ajaxStop(function()$(this).hide(); );rn $("#btnQSSQ_Post").ajaxStop(function()$(this).attr("disabled", false); );rn $("#btnQSSQ_Back").ajaxStop(function()$(this).attr("disabled", false); );rn $.ajax(rn rn url:"../actions/getWaterAction.aspx",rn type:"POST", rn dataType:"html",rn timeout:20000,rn data:"action=1&state=" + state + xmlParam,rn error: function(xhr) alert("服务器连接超时,请稍候重试!"); ,rn success:function(res) rn if(res == "0")rn alert("保存成功!");rn //chengmingrn if(state == 1)rn window.location.href = "qs_21.htm#fragment-2";rn rn if(state == 2)rn window.location.href = "qs_31.htm#fragment-2";rn rn //chengmingrn //window.location.reload();rn if(state == 0)rn window.location.href = "QS_2QSDJ.htm";rn rn rn if(state == 3)rn window.location.href = "QS_1.htm#fragment-2";rn rn rn else if(res == "-5")rn alert("用户信息已失效,请重新登陆后保存!");rn rn elsern alert("保存失败!");rn rn rn );rnrnrn//load qs infornrn //0 add 1change 2 extrnfunction qs_loadInfo(flag) rn $("#btnQSSQ_Post").ajaxStart(function()$(this).attr("disabled", true); );rn $("#btnQSSQ_Back").ajaxStart(function()$(this).attr("disabled", true); );rn rn $("#btnQSSQ_Post").ajaxStop(function()$(this).attr("disabled", false); );rn $("#btnQSSQ_Back").ajaxStop(function()$(this).attr("disabled", false); );rn $.ajax(rn rn url:"../actions/getWaterAction.aspx",rn type:"POST", rn dataType:"xml",rn timeout:20000,rn data:"action=2&state=" + flag,rn error: function(xhr) alert("服务器连接超时,请稍候重试!"); ,rn success:function(res)rn if($(res).find("qsInfo").attr("state") == "-5")rn alert("Session time out");rn rn elsern if($(res).attr("state") == "-6" && flag != "0")rn $("#btnQSSQ_Post").ajaxStart(function()$(this).attr("disabled", true); );rn $("#btnQSSQ_Back").ajaxStart(function()$(this).attr("disabled", true); );rn alert("请先录入取水申请!");rn return;rn rn rn qs_loadInfocallback(res);rn rn rn );rnrnrn//submit sqrnrnrnrnrn
问一下注释的写法
貌似有种注释方式(或者不叫注释), 可以把一段代码进行缩放操作.rn好像开头是 rn#regXXXXXrn结尾是:rn#endregXXXXXrnrn具体是什么? 好像没弄.NET. 都忘记了 , 悲剧
帮忙注释一下代码
packagern import flash.events.*;rn public class Thermometer extends EventDispatcherrn private var _temp:Number=32;rn public static const TEMP_CHANGED:String="tempChanged";rn public function set temp(newTemp:Number):voidrn _temp=newTemp;rn trace("Fired TEMP_CHANGED event");rn dispatchEvent(new Event(TEMP_CHANGED));rn rn public function get temp():Numberrn return _temp;rn rn rn rnrnpackagern import Thermometer;rn import flash.events.*;rn public class TempDisplayrn public function TempDisplay(thermometer:Thermometer)rn thermometer.addEventListener(Thermometer.TEMP_CHANGED,onTempChanged);rn rn protected function onTempChanged(event:Event):voidrn var thermometer:Thermometer=Thermometer(event.target);rn trace(thermometer.temp+"F");rn rn rn rnrnpackagern import flash.display.*;rn public class TemperatureMonitor extends Spritern protected var thermometer:Thermometer;rn protected var tempDisplayF:TempDisplay;rn public function TemperatureMonitor()rn thermometer=new Thermometer();rn tempDisplayF=new TempDisplay(thermometer);rn thermometer.temp=57;rn thermometer.temp=98.6;rn thermometer.temp=-12;rn rn rn
求一下文件注释
using System; rnusing System.Configuration; rnnamespace Maticsoft.DBUtility rn rn /// rn /// 公共工具类 rn /// rn public class PubConstant rn rn /// rn /// 获取固定连接字符串 rn /// rn public static string ConnectionString rn rn get rn rn string _connectionString = ConfigurationManager.AppSettings["[color=#FF0000][/color]cuowukuDBConnectionString"];rn string ConStringEncrypt = ConfigurationManager.AppSettings["[color=#FF0000][/color]connectionStrings"]; rn if (ConStringEncrypt == "true") rn rn _connectionString = DESEncrypt.Decrypt(_connectionString); rn rn return _connectionString; rn rn rn rn /// rn /// 动态得到web.config里配置项的数据库连接字符串。 rn /// rn /// rn /// rn public static string GetConnectionString(string configName) rn rn string connectionString = ConfigurationManager.AppSettings[configName]; rn string ConStringEncrypt = ConfigurationManager.AppSettings[[color=#FF0000][/color]"ConStringEncrypt"]; rn if (ConStringEncrypt == "true") rn rn connectionString = DESEncrypt.Decrypt(connectionString); rn rn return connectionString; rn rn rn rn rn rnrnrn尤其是红色部分 的rn
帮忙注释一下
Function chains() 'chains页面连锁酒店品牌图片rn Dim xml, strxml, j, array0, array1rn xml = Server.CreateObject("Microsoft.XMLDOM")rn xml.async = Falsern Dim HttpReq, xd, i, hotelid, krn k = 0rn HttpReq = server.CreateObject("Microsoft.XMLHTTP")rn HttpReq.open "GET",tcxmlapi&"getallpinpai.asp",Falsern HttpReq.send()rn strxml = HttpReq.responseTextrn xml.validateonparse = Truern xml.async = Falsern xml.loadXML(strXML)rn XMLlinks = xml.getElementsByTagName("pingpai")rn iLength = XMLLinks.lengthrn For i = 0 To iLength - 1rn xmlstring=xmlstring&XMLLinks(i).selectSingleNode("id").Text&","& XMLLinks(i).selectSingleNode("name").Text&","& XMLLinks(i).selectSingleNode("url").Text&"|"rn Nextrn array0 = Split(xmlstring, "|")rn If IsArray(array0) Thenrn Response.write(" ")rn For j = 0 To UBound(array0) - 1rn array1 = Split(array0(j), ",")rn If k Mod 8 = 0 Thenrn response.write(" ")rn End Ifrn response.write " "&Left(array1(1),5)&""rn k = k + 1rn Nextrn End Ifrn response.write("")rn XMLLinks = Nothingrn XMLItems = Nothingrn xml = Nothingrn End Functionrn
帮我注释一下代码
public void ExportControl(System.Web.UI.Control source, string DocumentType)rn rn rn HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("下载文件.doc", System.Text.Encoding.UTF8));rn HttpContext.Current.Response.ContentType = "application/ms-word";rnrnrn HttpContext.Current.Response.Charset = "UTF-8";rn HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;rn rn source.Page.EnableViewState = false;rn rn System.IO.StringWriter writer = new System.IO.StringWriter();rn System.Web.UI.HtmlTextWriter htmlWriter = new System.Web.UI.HtmlTextWriter(writer);rn source.RenderControl(htmlWriter);rn rn HttpContext.Current.Response.Write(writer.ToString());rn HttpContext.Current.Response.End();rn rn
帮我注释一下DBHelper
using System;rnusing System.Collections.Generic;rnusing System.Text;rnusing System.Data;rnusing System.Data.SqlClient;rnusing System.Configuration;rnrnnamespace MyBookShop.DALrnrn public static class DBHelperrn rn static string connectionString = ConfigurationManager.ConnectionStrings["MyBookShop"].ConnectionString;rn private static SqlConnection connection;rnrn public static SqlConnection Connectionrn rn get rn rn rn if (connection == null)rn rn connection = new SqlConnection(connectionString);rn connection.Open();rn rn else if (connection.State == System.Data.ConnectionState.Closed)rn rn connection.Open();rn rn else if (connection.State == System.Data.ConnectionState.Broken)rn rn connection.Close();rn connection.Open();rn rn return connection;rn rn rnrn public static SqlDataReader GetReader ( string sql )rn rn rn SqlCommand cmd = new SqlCommand();rn cmd.Connection = Connection;rn cmd.CommandText = sql;rnrn SqlDataReader dr= cmd.ExecuteReader(CommandBehavior.CloseConnection);rn return dr;rn rnrn public static DataTable GetDataTable ( string sql )rn rn rn DataSet ds = new DataSet();rnrn SqlDataAdapter sda = new SqlDataAdapter(sql,Connection);rnrn sda.Fill(ds,"mytable");rnrn return ds.Tables["mytable"];rn rnrnrnrn public static int ExecuteCommand(string safeSql)rn rn SqlCommand cmd = new SqlCommand(safeSql, Connection);rn int result = cmd.ExecuteNonQuery();rn return result;rn rnrn public static int ExecuteCommand(string sql, params SqlParameter[] values)rn rn SqlCommand cmd = new SqlCommand(sql, Connection);rn cmd.Parameters.AddRange(values);rn return cmd.ExecuteNonQuery();rn rnrn public static int GetScalar(string safeSql)rn rn SqlCommand cmd = new SqlCommand(safeSql, Connection);rn int result = Convert.ToInt32(cmd.ExecuteScalar());rn return result;rn rnrn public static int GetScalar(string sql, params SqlParameter[] values)rn rn SqlCommand cmd = new SqlCommand(sql, Connection);rn cmd.Parameters.AddRange(values);rn int result = Convert.ToInt32(cmd.ExecuteScalar());rn return result;rn rnrn //public static SqlDataReader GetReader(string safeSql)rn //rn // SqlCommand cmd = new SqlCommand(safeSql, Connection);rn // SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);rn // return reader;rn //rnrn public static SqlDataReader GetReader(string sql, params SqlParameter[] values)rn rn SqlCommand cmd = new SqlCommand(sql, Connection);rn cmd.Parameters.AddRange(values);rn SqlDataReader reader = cmd.ExecuteReader();rn return reader;rn rnrn public static DataTable GetDataSet(string safeSql)rn rn DataSet ds = new DataSet();rn SqlCommand cmd = new SqlCommand(safeSql, Connection);rn SqlDataAdapter da = new SqlDataAdapter(cmd);rn da.Fill(ds);rn return ds.Tables[0];rn rnrn public static DataTable GetDataSet(string sql, params SqlParameter[] values)rn rn DataSet ds = new DataSet();rn SqlCommand cmd = new SqlCommand(sql, Connection);rn cmd.Parameters.AddRange(values);rn SqlDataAdapter da = new SqlDataAdapter(cmd);rn da.Fill(ds);rn return ds.Tables[0];rn rnrn rnrn
请注释一下执行过程
public partial class Form1 : Formrn rn public Form1()rn rn InitializeComponent();rn rn static int x = 200;rn static int y = 200;rn private void button1_Click(object sender, EventArgs e)rn rn Form1 form2 = new Form1();rn form2.Visible = true;rn form2.SetDesktopLocation(x, y); [color=#FF0000]//?[/color]rn x += 30;rn y += 30;rn this.Activate(); [color=#FF0000]//?[/color]rn this.Button1.Enabled = false; [color=#FF0000]//?[/color]rn rn private void Form1_Activated(object sender, System.EventArgs e)rn rn Label1.Text = "x: " + x + " y: " + y;rn Label2.Text = "Number of forms currently open: " + count;rn rn static int count = 0;rnrn private void Form1_Closed(object sender, System.EventArgs e)rn rn count -= 1[color=#FF0000];//?[/color]rn rn private void Form1_Load(object sender, System.EventArgs e)rn rn count += 1; [color=#FF0000]//?[/color]rn rn rnrn rnrn上面这段代码,看不懂,麻烦注释一下执行过程,谢谢
请帮我注释一下!!!!!
请帮我注释一下,thank you!rnrnrn rnrnrn rnrnrn
相关热词 c# stream 复制 android c# c#监测窗口句柄 c# md5 引用 c# 判断tabtip 自己写个浏览器程序c# c# 字符串变成整数数组 c#语言编程写出一个方法 c# 转盘抽奖 c#选中treeview