标题:连接错误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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-364729-1-1.html




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

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