Solved

Rogue Wave RWTPtrHashDictionary-template as static

Posted on 1997-05-09
3
507 Views
Last Modified: 2008-02-26
I am trying to use the RWTPtrHashDictionary-template 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)(const RWCString& string);

unsigned hashString(const RWCString& string)
{
  return string.hash();
}

class Fails
{
  static RWTPtrHashDictionary< RWCString, RWCString >
_dict(RWCStringHashFunction);

  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/include
-I/opt/SUNWspro/SC4.0/include/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.dat
### CC: Note: NLSPATH =
/opt/SUNWspro/bin/../SC4.0/bin/../lib/locale/C/LC_MESSAGES/%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/include
-I/opt/SUNWspro/SC4.0/include/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/include
-I/opt/SUNWspro/SC4.0/include/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/include/CC -I/opt/SUNWspro/SC4.0/include/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(*)(const
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
0
Comment
Question by:ttbwt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Accepted Solution

by:
dkarr earned 100 total points
ID: 1163363
Your member "_dict" is actually being declared as a member function which returns a RWTPtrHashDictionary and has a single parameter which is a RWCStringHashFunction.  If you meant this to be a function, you need to define its implementation.  The form you are trying to use to define it makes it look (and I believe you thought) like a data member, but it is not.
0
 

Author Comment

by:ttbwt
ID: 1163364
He didn't tell me how to solve the problem, only that there is
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.
0
 

Expert Comment

by:dkarr
ID: 1163365
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<RWCString, RWCString> Fails::_dict(hashString);

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question