From: drathj01 AT xlab1 DOT fiu DOT edu (daniel k rathjens) Newsgroups: comp.os.msdos.djgpp Subject: error in method '__as' Date: 16 Jun 1997 07:23:25 GMT Organization: Florida International University Lines: 128 Message-ID: <5o2pld$793@isis.fiu.edu> NNTP-Posting-Host: xlab1.fiu.edu To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk I am writing a linked list implementation of a queue class that uses iterators and I am getting the following error when I compile: In function 'int main()': myq.h(44) Error: inconsistent return types for method '__as' in class 'Queue' Line 44 is the end of my class declaration. Is '__as' some kind of assembler optimization the compiler is making? (I compiled a version that just used pointers for front and back and it worked fine) Here is myq.h and after that myq.cc: // ******************PUBLIC OPERATIONS********************* // void Enqueue( Etype X )--> Insert X // void Dequeue( ) --> Remove least recently inserted item // Etype Front( ) --> Return least recently inserted item // int IsEmpty( ) --> Return 1 if empty; else return 0 // int IsFull( ) --> Return 1 if full; else return 0 // void MakeEmpty( ) --> Remove all items // ******************ERRORS******************************** // Predefined exception is propogated if new fails // EXCEPTION is called for Front or Dequeue on empty queue #ifndef __Queue #define __Queue #include #include "List.h" template class Queue { public: Queue( ) : _Front( _Line ), _Back( _Line ) { } ~Queue( ); Queue & operator=( const Queue & Rhs ); void Enqueue( const Etype & X ); void Dequeue( ); const Etype & Front( ) const; int IsEmpty( ) const { return +_Front; } int IsFull( ) const { return 0; } void MakeEmpty( ); private: List _Line; ListItr _Front; ListItr _Back; }; #endif and here is myq.cc: #include "myq.h" #include "Exception.h" template Queue::~Queue( ) { MakeEmpty( ); } template const Queue & Queue::operator=( const Queue & Rhs ) { if( this == &Rhs ) return Rhs; MakeEmpty( ); if( Rhs.IsEmpty( ) ) return *this; ListItr RhsItr = Rhs; for ( RhsItr.First(); +RhsItr(); ++RhsItr() ) { Enqueue( RhsItr() ); } return *this; } template void Queue::Enqueue( const Etype & X ) { if( IsEmpty( ) ) { _Back.Insert( X ); // inserts first item into queue and _Front.First(); // makes front point at first item } else _Back.Insert( X ); // otherwise just insert item at the back } template void Queue::Dequeue( ) { EXCEPTION( IsEmpty( ), "Queue is empty" ); _Front.Zeroth(); // moving _Front to header so I can use RemoveNext // to dequeue the first item _Front.RemoveNext(); if ( !IsEmpty() ) _Front.First(); // moving _Front to the first item so Front // will return the right value else _Back.Zeroth(); // since I just removed last item, _Back has // to point at the header now } template const Etype & Queue::Front( ) const { EXCEPTION( IsEmpty( ), "Queue is empty" ); return &_Front(); } template void Queue::MakeEmpty( ) { while( !IsEmpty( ) ) Dequeue( ); } -- #include #include void main(geek *code) { // pointer points to: Danny Rathjens GCS/M/S d+(-) s+:- a-- C+++>$ ULSC++>+++$ P+? L++ E W++(+) N+++ o K w++ !O !M- V- PS PE+ Y-- PGP- t++@ !5 X+ R+ tv b+++ DI+ D+ G++ e+ h r y? }