...

View Full Version : Class prototype not recognized in class implementation



Phoncible
09-28-2008, 04:44 AM
So here's the class definition:



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


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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum