c++线性表类 出错求解决!!

想用c++实现线性表,把线性表作为一个类,进行类的插入删除查找等功能,写了一个头文件和源文件,虽然能运行,但不会显示东西好像没成功,请问哪些地方错了,如何改进
下面是头文件

#ifndef _LINEAR_H
#define _LINEAR_H 
#include<iostream>
using namespace std;

class linear 
{
    class Node
    {
    public:/*这两个设置为私有的无法访问 为什么 都写到类里面了 或者这个写到类外面要怎么处理*/ 
        int value;
        Node *next;

        Node(int x=0)
        {
        value=x;
        next=0;
        }
    } *head;
    
    public:
        void Insert(int pos,int value);//pos位置,value值 
        int Delete(int pos,int *value);
        int Find(int value);
        linear()//构造函数 
        {
            head=new Node;
            if(!head) 
            throw -1;
        }
    
        ~linear()//析构函数 
        {
            delete head;
        }
};

void linear::Insert(int pos,int value)
{
    Node *p=head;
    int c=1;
    
    while(c<pos||!p->next)
    {
        p=p->next;
        c++;
    
    }
    Node *q=new Node(value);
    if(!q) throw -1;
    q=p->next;
    p->next=q;
    cout<<"已插入"<<value;  
}

int linear::Delete(int pos,int *value)
{
    Node *p=head;
    int c=1;
    
    while(c<pos||!p->next)
    {
        p=p->next;
        c++;
    }
    
    if(p->next)
    {
        Node *q=p->next;
        *value=q->value;
        p->next=q->next;
        delete q; 
    }
}

int linear::Find(int value)
{
    Node *p=head->next;
    int c=1;
    while(!p)
    {
        if(p->value==value)
        {
            cout<<"找到"; 
            c=0;
            return c;
        }
        
        p=p->next;
        c++; 
    }
    if(c==1)
    cout<<"未找到"; 
    return -1;
}

#endif

下面是源文件

#include"linear.h"

int main()
{
    linear biao;
    biao.Insert(1,3);
    biao.Insert(2,0);
    biao.Insert(3,7);
    biao.Insert(4,9);
    biao.Find(3);
    int value=3;
    biao.Delete(2,&value);
    return 0;

}

  • while 的查找 条件应该为与
while (!p->next &&c< pos)

或有短路,如果给一个特别大的 pos 这里会出问题。

  • Insert 里边 插入那部分应该是
q->next = p->next;
p->next = q;
  • Find 那里 不应该判断 c 为 1的时候没找到,应该是 走出循环就是没找到