Re: Compile errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Parms,

  You are using the stl_hash_fun.h header file so hash is declared
inside the stl namespace.  You need to fully qualify it with the std::
namespace or add

using std::hash; 

Beneath the includes.

corey

On Mon, 28 Mar 2005 09:29:10 -0800 (PST), Parms singh
<list_track@xxxxxxxxx> wrote:
> Hello,
> 
> I am running gcc version 3.2.2 20030222 (Red Hat Linux
> 3.2.2-5).
> 
> I am a relative newbee to c++ (haven't used it in a
> while).
> 
> In my .h file:
> #include <ext/stl_hash_fun.h>
> #include <ext/hash_map>
> 
> class HTEntry {
> public:
>         double time;
>         double ttl;
> };
> 
> typedef hash_map<int, pair<int,HTEntry>, hash<int>,
> equal_to<int> > HMap;
> 
> class Hash_Table
> {
> public:
>         void increment(int, double, double);
>         int lookup(int,double,double);
>         int findsize(double,bool);
>         int estimate_hit(double);
> protected:
>         HMap flows;
> };
> 
> In the .cc file:
> #include <iostream>
> #include <sstream>
> #include <cmath>
> #include <valarray>
> #include <string>
> #include <sys/types.h>
> #include "config.h"
> #include "template.h"
> #include "flags.h"
> #include "delay.h"
> #include "rd.h"
> 
> using namespace std;
> 
> void Hash_Table::increment(int id, double t_now,
> double ttl)
> {
>         HMap::iterator iter;
>         iter=flows.find(id);
>         double timelived, thresh;
>         int hits;
>  // bunch of stuff
> }
> 
> //other functions that I leave out.
> 
> Errors:
> In file included from qd.cc:78:
> qd.h:154: `hash' was not declared in this scope
> qd.h:154: parse error before `>' token
> qd.h:173: 'HMap' is used as a type, but is not defined
> as a type.
> qd.cc: In member function `void
> Hash_Table::increment(int, double, double)':
> qd.cc:1232: `HMap' undeclared (first use this
> function)
> qd.cc:1232: (Each undeclared identifier is reported
> only once for each
>    function it appears in.)
> qd.cc:1232: parse error before `::' token
> qd.cc:1233: `iter' undeclared (first use this
> function)
> qd.cc:1233: `flows' undeclared (first use this
> function)
> qd.cc: In member function `int
> Hash_Table::findsize(double, bool)':
> qd.cc:1274: parse error before `::' token
> qd.cc: In member function `int Hash_Table::lookup(int,
> double, double)':
> qd.cc:1360: parse error before `::' token
> make: *** [qd.o] Error 1
> 
> Similar errors for other functions removed for
> simplicity.
> 
> Any help is appreciated.
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Small Business - Try our new resources site!
> http://smallbusiness.yahoo.com/resources/
>

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux