ttbwt
asked on
Rogue Wave RWTPtrHashDictionary-template as static
I am trying to use the RWTPtrHashDictionary-templ ate as a static member
in a class, but my attempt at it fails to compile.
I am using Solaris2.5.1 with Sun C++-compiler 4.1. The Tools.h I use
is the one that comes with SunSoft VisualWorkshop C++ v 2.1.
Thanks a lot for any help
regards bård
My code:
#include <rw/tpordvec.h>
#include <rw/tphdict.h>
#include <rw/cstring.h>
typedef unsigned (*RWCStringHashFunction)(c onst RWCString& string);
unsigned hashString(const RWCString& string)
{
return string.hash();
}
class Fails
{
static RWTPtrHashDictionary< RWCString, RWCString >
_dict(RWCStringHashFunctio n);
static RWTPtrOrderedVector< RWCString > _slask;
Fails();
};
RWTPtrOrderedVector< RWCString > Fails::_slask; // ok
RWTPtrHashDictionary< RWCString, RWCString > Fails::_dict(hashString);
//fails to compile
Fails::Fails()
{
}
and the what the compiler thinks of it:
cd /home/inga/ttbwt/MOS/lib/
make -k Fails.o
CC -g -D__BUILTIN_VA_ARG_INCR -v -V -ptv -sb -I.
-I/home/inga/ttbwt/FMNETT/ lib -I/usr/openwin/share/inclu de
-I/opt/SUNWspro/SC4.0/incl ude/CC -I/usr/openwin/include -DSVR4
-DSYSV -c Fails.C
CC: SC4.0 18 Oct 1995 C++ 4.1
### CC: Note: LM_LICENSE_FILE = /progs/dtidir/dtilicense.d at
### CC: Note: NLSPATH =
/opt/SUNWspro/bin/../SC4.0 /bin/../li b/locale/C /LC_MESSAG ES/%N
/opt/SUNWspro/bin/../SC4.0 /bin/ccfe -sb -y-o -yFails.o -V -I.
-I/home/inga/ttbwt/FMNETT/ lib -I/usr/openwin/share/inclu de
-I/opt/SUNWspro/SC4.0/incl ude/CC -I/usr/openwin/include -y-fbe
-y/opt/SUNWspro/bin/../SC4 .0/bin/fbe -y-xarch=generic -y-verbose -O0
-ptf /tmp/18180%1.%2 -ptv -ptx /opt/SUNWspro/bin/../SC4.0 /bin/CC -ptk
"-g -D__BUILTIN_VA_ARG_INCR -v -ptv -sb -I.
-I/home/inga/ttbwt/FMNETT/ lib -I/usr/openwin/share/inclu de
-I/opt/SUNWspro/SC4.0/incl ude/CC -I/usr/openwin/include -DSVR4 -DSYSV -c
" -D__SunOS_5_5_1 -D__SUNPRO_CC=0x410 -Dunix -Dsun -Dsparc -D__sparc
-D__unix -D__sun -D__BUILTIN_VA_ARG_INCR -D__SVR4 -g +d -y-g
-I/opt/SUNWspro/SC4.0/incl ude/CC -I/opt/SUNWspro/SC4.0/incl ude/cc
-D__BUILTIN_VA_ARG_INCR -DSVR4 -DSYSV Fails.C -s /tmp/ccfe.18180.0.s
ccfe: SC4.0 10 May 1996 patch 102934-06
"Fails.C", line 23: Error: static Fails::_dict(unsigned(*)(c onst
RWCString&)) is not a static data member.
1 Error(s) detected.
*** Error code 1
make: Warning: Target `Fails.o' not remade because of errors
Compilation finished at Thu May 8 10:50:08
in a class, but my attempt at it fails to compile.
I am using Solaris2.5.1 with Sun C++-compiler 4.1. The Tools.h I use
is the one that comes with SunSoft VisualWorkshop C++ v 2.1.
Thanks a lot for any help
regards bård
My code:
#include <rw/tpordvec.h>
#include <rw/tphdict.h>
#include <rw/cstring.h>
typedef unsigned (*RWCStringHashFunction)(c
unsigned hashString(const RWCString& string)
{
return string.hash();
}
class Fails
{
static RWTPtrHashDictionary< RWCString, RWCString >
_dict(RWCStringHashFunctio
static RWTPtrOrderedVector< RWCString > _slask;
Fails();
};
RWTPtrOrderedVector< RWCString > Fails::_slask; // ok
RWTPtrHashDictionary< RWCString, RWCString > Fails::_dict(hashString);
//fails to compile
Fails::Fails()
{
}
and the what the compiler thinks of it:
cd /home/inga/ttbwt/MOS/lib/
make -k Fails.o
CC -g -D__BUILTIN_VA_ARG_INCR -v -V -ptv -sb -I.
-I/home/inga/ttbwt/FMNETT/
-I/opt/SUNWspro/SC4.0/incl
-DSYSV -c Fails.C
CC: SC4.0 18 Oct 1995 C++ 4.1
### CC: Note: LM_LICENSE_FILE = /progs/dtidir/dtilicense.d
### CC: Note: NLSPATH =
/opt/SUNWspro/bin/../SC4.0
/opt/SUNWspro/bin/../SC4.0
-I/home/inga/ttbwt/FMNETT/
-I/opt/SUNWspro/SC4.0/incl
-y/opt/SUNWspro/bin/../SC4
-ptf /tmp/18180%1.%2 -ptv -ptx /opt/SUNWspro/bin/../SC4.0
"-g -D__BUILTIN_VA_ARG_INCR -v -ptv -sb -I.
-I/home/inga/ttbwt/FMNETT/
-I/opt/SUNWspro/SC4.0/incl
" -D__SunOS_5_5_1 -D__SUNPRO_CC=0x410 -Dunix -Dsun -Dsparc -D__sparc
-D__unix -D__sun -D__BUILTIN_VA_ARG_INCR -D__SVR4 -g +d -y-g
-I/opt/SUNWspro/SC4.0/incl
-D__BUILTIN_VA_ARG_INCR -DSVR4 -DSYSV Fails.C -s /tmp/ccfe.18180.0.s
ccfe: SC4.0 10 May 1996 patch 102934-06
"Fails.C", line 23: Error: static Fails::_dict(unsigned(*)(c
RWCString&)) is not a static data member.
1 Error(s) detected.
*** Error code 1
make: Warning: Target `Fails.o' not remade because of errors
Compilation finished at Thu May 8 10:50:08
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
As I alluded to before, we need to change _dict from a function into an object.
Change your class declaration to the following:
class Fails
{
Fails();
static RWTPtrHashDictionary< RWCString, RWCString > _dict;
static RWTPtrOrderedVector< RWCString > _slask;
};
RWTPtrOrderedVector< RWCString > Fails::_slask;
RWTPtrHashDictionary<RWCSt ring, RWCString> Fails::_dict(hashString);
Change your class declaration to the following:
class Fails
{
Fails();
static RWTPtrHashDictionary< RWCString, RWCString > _dict;
static RWTPtrOrderedVector< RWCString > _slask;
};
RWTPtrOrderedVector< RWCString > Fails::_slask;
RWTPtrHashDictionary<RWCSt
ASKER
a problem and a vague hint as to where the problem is.
I am still at a loss as to what to do, so I would like to know
how to actually resolve the problem.