2013-09-05 3 views
0

У меня есть два файла ll.cpp и ll.h как в том же каталоге.Неустранимая ошибка: ll.h: Нет такого файла или каталога

ll.cpp

#include <ll.h> 

#include <iostream> 

using namespace std; 




    template <class t> 
    LinkedL<t>::LinkedL() 
    { 
     flag=0; 
     head=NULL; 
     tail=NULL; 
     curr=0; 
    } 
    template <class t> 
    LinkedL<t>::void insertS(t inf) 
    { 
     Node<t> *n=new Node<t>; 
     n->next=head; 
     n->data=inf; 
     head=n; 
     if(curr==0) 
      tail=n; 
     curr++; 
     //cout<<curr<<"\n"; 
    } 
    template <class t> 
    LinkedL<t>::void insertE(t inf) 
    { 
     Node<t> *n=new Node<t>; 
     n->next=NULL; 
     n->data=inf; 
     if(curr!=0) 
     tail->next=n; 
     tail=n; 
     if(curr==0) 
      head=n; 
     curr++; 
     //cout<<curr<<"\n"; 
    } 
    template <class t> 
    LinkedL<t>::t delS() 
    { 
     if(curr>=1) 
     { 
      flag=1; 
      t temp=head->data; 
      Node<t> *n=head; 
      head=head->next; 
      if(head==NULL) 
       tail=NULL; 
      delete n; 
      curr--; 
      return temp; 
     } 
     else 
     { 
      cout<<"EMPTY LIST\n"; 
     } 
    } 
    template <class t> 
    LinkedL<t>::t delE() 
    { 

     if(curr>=1) 
     { 
      flag=1; 
      Node<t> *n=head; 
      t temp; 
      if(curr>1) 
      { 
       while(n->next!=tail) 
        { 
         //cout<<n->data<<" "; 
         n=n->next; 
        } 
        //cout<<"\n"; 
       Node<t> *n1=tail; 
       temp=n1->data; 
       tail=n; 
       tail->next=NULL; 
       //cout<<n->data<<"\n"; 
       delete n1; 
       } 
       else if(curr==1) 
       { 
        temp=tail->data; 
        delete tail; 
        head=NULL; 
        tail=NULL; 
       } 

       curr--; 
       //cout<<curr<<"\n"; 
       return temp; 
     }else if(curr==0) 
     { 
      cout<<"EMPTY LIST\n"; 
     } 

    } 
    template <class t> 
    LinkedL<t>::bool search(t inf) 
    { 
     Node<t> *n=head; 
     while(n!=NULL && n->data!=inf) 
      n=n->next; 
     if(n==NULL) 
      return false; 
     return true; 
    } 
    template <class t> 
    LinkedL<t>::void traverse() 
    { 
     if(curr!=0) 
     { 
      Node<t> *n=head; 
      while(n!=NULL) 
       { 
       cout<<n->data<<" "; 
       n=n->next; 
       } 
      cout<<'\n'; 
     } 
     else 
     { 
      cout<<"EMPTY\n"; 
     } 
    } 
    template <class t> 
    LinkedL<t>::bool isEmpty() 
    { 
     if(curr==0) 
      return true; 
     return false; 
    } 
    template <class t> 
    LinkedL<t>::t at(int i) 
    { 
     if(i<=curr) 
     { 
      flag=1; 
      Node<t> *n=head; 
      int k=1; 
      while(k!=i) 
      { 
       n=n->next; 
       k++; 
      } 
      return n->data; 
     } 
     else 
      cout<<"Invalid Index\n"; 
    } 
    template <class t> 
    LinkedL<t>::void insert(int i,t dat) 
    { 
     if(i<=curr+1) 
     { 
      flag=1; 
      if(curr==0 || i==1) 
      { 
       insertS(dat); 
      } 
      else 
      { 
       Node<t> *n1=NULL; 
       Node<t> *n=head; 
       int k=1; 
       while(k!=i) 
       { 
        n1=n; 
        n=n->next; 
        k++; 
       } 
       Node<t> *temp=new Node<t>; 
       temp->next=n; 
       n1->next=temp; 
       temp->data=dat; 
       curr++; 
      } 
     } 
     else 
      cout<<"Invalid Index\n"; 
    } 
    template <class t> 
    LinkedL<t>::void reverse() 
    { 
     if(curr!=0) 
     { 
      Node<t> *n=head; 
      Node<t> *n1=head; 
      Node<t> *n2=NULL; 
      while(n!=NULL) 
      { 
       n1=n->next; 
       n->next=n2; 
       n2=n; 
       n=n1; 
      } 
      n=head; 
      head=tail; 
      tail=n; 
     } 
    } 
    template <class t> 
    LinkedL<t>::t delet(int i) 
    { 
     Node<t> *n=head; 
     if(head!=NULL && i<=curr) 
     { 
      flag=1; 
      t dat; 
      int k=1; 
      if(i==1) 
       dat=delS(); 
      else 
      { 
       while(k!=i-1) 
        { 
         n=n->next; 
         k++; 
        } 
       Node<t> *n1=n->next; 
       n->next=n->next->next; 
       dat=n1->data; 
       delete n1; 
      } 
      curr--; 
      return dat; 
     } 
     else 
     { 
      cout<<"Invalid Index\n"; 
     } 
    } 

ll.h

#ifndef LL_H 
#define LL_H 

template <class t> 
class Node 
{ 
    public: 
    Node<t> * next; 
    t data; 
}; 


template <class t> 
class LinkedL 
{ 
    private: 
     Node<t>* head; 
     Node<t>* tail; 
     int curr; 
    public: 
    int flag; 
    LinkedL(); 

    void insertS(t inf); 

    void insertE(t inf); 

    t delS(); 

    t delE(); 

    bool search(t inf); 

    void traverse(); 


    bool isEmpty(); 

    t at(int i); 

    void insert(int i,t dat); 

    void reverse(); 

    t delet(int i); 


}; 
#endif 

Я не могу понять, почему компилятор дает эту ошибку. То же самое происходит для всех пар .h и .cpp в качестве перекрестной проверки. Я изменил разрешение на rwx для всех пользователей, но по-прежнему происходит такая же ошибка. Пожалуйста помоги.

+2

Попробуйте '#include "ll.h"' – 0x499602D2

+0

@ 0x499602D2 это работает, кстати, в чем разница между использованием <> для включения и "" – user2179293

+0

@ user2179293 <> является для системных заголовков. «» - для локальных и проектных заголовков. –

ответ

4

Если вы включили что-то и напишите его <>, препроцессор выполняет поиск во внешних библиотеках, таких как библиотека std. Подобно тому, что вы сделали здесь:

#include <iostream> 

Но если включить ваши собственные .cpp или .h файлов используют "" поэтому он будет искать в локальном каталоге. Поэтому использовать в этом случае:

#include "ll.h" 
Смежные вопросы