Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    Aug 2008
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Class prototype not recognized in class implementation

    So here's the class definition:

    Code:
    namespace whatever
    {
        class bag
        { 
        public:
            // TYPEDEFS and MEMBER CONSTANTS
            typedef int value_type;
            typedef std::size_t size_type;
            static const size_type CAPACITY = 30;
            // CONSTRUCTOR
            bag( ) { used = 0; } 
            // MODIFICATION MEMBER FUNCTIONS
            size_type erase(const value_type& target);
            bool erase_one(const value_type& target);
            void insert(const value_type& entry);
            void operator +=(const bag& addend);
            // CONSTANT MEMBER FUNCTIONS
            size_type size( ) const { return used; }
            size_type count(const value_type& target) const;
            value_type minimum() const;                //this is one with problem
        private:
            value_type data[CAPACITY];  // The array to store items
            size_type used;             // How much of array is used
        };
    
        // NONMEMBER FUNCTIONS for the bag class
        bag operator +(const bag& b1, const bag& b2);
    In the implementation file, the "minimum()" function is
    Code:
    bag::value_type bag::minimum() const
    {                                   
       assert(size() > 0);              
       size_type i;                     
       value_type temp;                 
       for (i = 1; i < used; i++)       
           if (data[i-1] < data[i])     
           {                            
              temp = data[i-1];         
              data[i-1] = data[i];      
              data[i] = temp;           
           }                            
       return data[used-1];             
    }
    When I compile the implementation file, it gives a warning saying

    no `int main_savitch_3::bag::minimum() const' member function declared in class `main_savitch_3::bag'

    I don't get it, what am I doing wrong? Thanks for any help.

    EDIT: Sorry, I always do this, look look look, never find, post question, then find "why". I had the #include wrong for the header file.
    Last edited by Phoncible; 09-28-2008 at 04:24 AM.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •