| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 336 人关注过本帖
标题:连接错误2001
只看楼主 加入收藏
tianyi1993
Rank: 1
等 级:新手上路
帖 子:23
专家分:9
注 册:2012-1-24
结帖率:83.33%
收藏
 问题点数:0 回复次数:0 
连接错误2001
#ifndef DOG
#define DOG
struct Node
{
    int info;
    Node *next;
};
class Clist
{
public:
    Clist()
    {
        head=NULL;
    }
    void insert(int a,int b);
    void deletelist(int a);
    void output();
private:
    Node *head;
    int a,b;
};                          
#endif
头文件
#include<iostream>
#include"List.h"
using namespace std;
void Clist::insert(int a,int b)
{
    Node *p,*q,*s;
    s=(Node*)new(Node);
    s->info=b;
    p=head;
    if(head==NULL)
    {
        head=s;
        s->next=NULL;
    }
    else if(p->info==a)
    {
        s->next=head;
        head=s;
    }
    else
        while(p->info!=a&&p->next!=NULL)
        {
            q=p;
            p=p->next;
        }
        if(p->info==a)
        {
            q->next=s;
            s->next=p;
        }
        else
        {
            p->next=s;
            s->next=NULL;
        }
}
void Clist::deletelist(int a)
{
    Node *p,*q;
    p=head;
    if(p==NULL)
    return;
    if(p->info==a)
    {
        head=p->next;
        delete p;
    }
    else
    {
        while(p->info!=a&&p->next!=NULL)
        {
            q=p;
            p=p->next;
        }
        if(p->info==a)
        {
            q->next=p->next;
            delete p;
        }
    }
}
这是函数实现

#include<iostream>
#include"List.h"
using namespace std;
int main()
{
    int m[]={11,12,13,14,15,16,17,18,19,20},i;
    Clist obj1,obj2;
    obj1.insert(0,m[0]);
    for(i=0;i<10;i++)
        obj1.insert(0,m[i]);
    obj1.output();
    return 0;
}
这是主函数

通过调试了,通不过编译,请大家帮忙看看,,,,,,,,,,,,,,,,,,,






搜索更多相关主题的帖子: head void private include public 
2012-03-29 21:17
快速回复:连接错误2001
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014141 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved