c++ - implementation of queue -


it self learning process design queue here code

#include <iostream> using namespace std; template <class t> class queue{  public:      t * q;      int n, head, tail; public:        queue(int maxn){             q=new t[maxn+1];            n=maxn+1; head=n;             tail=0;           }         int  emty() const {             return ((head%n)==tail);          }         void put(t k){             a[tail++]=k; tail=tail%n;           }           t get(){               head=head%n;  return q[head++];            } }; template <class t> int main(){      queue<int>a(10);     a.put(13);     a.put(45);     a.put(12);     a.put(10);     a.put(30);     a.put(45);     while(!a.emty()){         cout<<a.get()<<"  ";       }      return 0; } 

here mistakes

1>------ build started: project: queue, configuration: debug win32 ------ 1>msvcrtd.lib(crtexe.obj) : error lnk2019: unresolved external symbol _main referenced in function ___tmaincrtstartup 1>d:\c++_algorithms\queue\debug\queue.exe : fatal error lnk1120: 1 unresolved externals ========== build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 

please help

the main function mustn’t template. remove template <class t> before remove compile error.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -