C++ : Miscellaneous technical and environmental issues


Miscellaneous technical issues:

Q131: Why are classes with static data members getting linker errors?
A: Static member variables must be given an explicit definition in exactly one
module.  Ex:
	class X {
	  static int i;  //*declare* static member X::i
The linker will holler at you (`X::i is not defined') unless (exactly) one of
your source files has something like the following:
	int X::i = some_expression_evaluating_to_an_int;     //*define* X::i
	int X::i;                     //define --but don't initialize-- X::i

The usual place to define static member variables of class `X' is file `X.C'
(or X.cpp, X.cc, X.c++, X.c or X.cxx; see question on file naming conventions).

Q132: What's the difference between the keywords struct and class?
A: The members and base classes of a struct are public by default, while in
class, they default to private.  Base classes of a struct are public by default
while they are private by default with `class' (however you should make your
base classes *explicitly* public, private, or protected).  `Struct' and `class'
are otherwise functionally equivalent.

Q133: Why can't I overload a function by its return type?

Ex: the compiler says the following two are an error:
	char  f(int i);
	float f(int i);

A: Return types are not considered when determining unique signatures for
overloading functions; only the number and type of parameters are considered.
Reason: which function should be called if the return value is ignored?  Ex:

	  f(3);  //which should be invoked??

Q134: What is `persistence'?  What is a `persistent object'?
A: Loosely speaking, a persistent object is one that lives on after the
program which created it has stopped.  Persistent objects can even outlive
various versions of the creating program, can outlive the disk system, the
operating system, or even the hardware on which the OS was running when
they were created.

The challenge with persistent objects is to effectively store their method
code out on secondary storage along with their data bits (and the data bits
and method code of all subobjects, and of all their subobjects, etc).  This
is non-trivial when you have to do it yourself.  In C++, you have to do it
yourself.  C++/OO databases can help hide the mechanism for all this.

Miscellaneous environmental issues:

Q135: Is there a TeX or LaTeX macro that fixes the spacing on `C++'?
A: Yes, here are two:

\def\CC{C\raise.22ex\hbox{{\footnotesize +}}\raise.22ex\hbox{\footnotesize +}}

\def\CC{{C\hspace{-.05em}\raisebox{.4ex}{\tiny\bf ++}}}

Q136: Where can I access C++2LaTeX, a LaTeX pretty printer for C++ source?
A: Here are a few ftp locations:

Host aix370.rrz.uni-koeln.de   ( Last updated 15:41 26 Apr 1991
    Location: /tex
      FILE      rw-rw-r--     59855  May  5  1990   C++2LaTeX-1.1.tar.Z
Host utsun.s.u-tokyo.ac.jp   ( Last updated 05:06 20 Apr 1991
    Location: /TeX/macros
      FILE      rw-r--r--     59855  Mar  4 08:16   C++2LaTeX-1.1.tar.Z
Host nuri.inria.fr   ( Last updated 05:23  9 Apr 1991
    Location: /TeX/tools
      FILE      rw-rw-r--     59855  Oct 23 16:05   C++2LaTeX-1.1.tar.Z
Host iamsun.unibe.ch   ( Last updated 05:06  4 Apr 1991
    Location: /TeX
      FILE      rw-r--r--     59855  Apr 25  1990   C++2LaTeX-1.1.tar.Z
Host iamsun.unibe.ch   ( Last updated 05:06  4 Apr 1991
    Location: /TeX
      FILE      rw-r--r--     51737  Apr 30  1990
Host tupac-amaru.informatik.rwth-aachen.de   ( Last updated 05:07 18 Apr 1991
    Location: /pub/textproc/TeX
      FILE      rw-r--r--     72957  Oct 25 13:51  C++2LaTeX-1.1-PL4.tar.Z
Host wuarchive.wustl.edu   ( Last updated 23:25 30 Apr 1991
    Location: /packages/tex/tex/
      FILE      rw-rw-r--     49104  Apr 10  1990   C++2LaTeX-PL2.tar.Z
      FILE      rw-rw-r--     25835  Apr 10  1990   C++2LaTeX.tar.Z
Host tupac-amaru.informatik.rwth-aachen.de   ( Last updated 05:07 18 Apr 1991
    Location: /pub/textproc/TeX
      FILE rw-r--r-- 74015  Mar 22 16:23 C++2LaTeX-1.1-PL5.tar.Z
    Location: /pub
      FILE rw-r--r-- 74015  Mar 22 16:23 C++2LaTeX-1.1-PL5.tar.Z
Host sol.cs.ruu.nl   ( Last updated 05:10 15 Apr 1991
    Location: /TEX/TOOLS
      FILE      rw-r--r--     74015  Apr  4 21:02x   C++2LaTeX-1.1-PL5.tar.Z
Host tupac-amaru.informatik.rwth-aachen.de ( Last updated 05:07 18 Apr 1991
    Location: /pub/textproc/TeX
      FILE      rw-r--r--      4792  Sep 11  1990 C++2LaTeX-1.1-patch#1
      FILE      rw-r--r--      2385  Sep 11  1990 C++2LaTeX-1.1-patch#2
      FILE      rw-r--r--      5069  Sep 11  1990 C++2LaTeX-1.1-patch#3
      FILE      rw-r--r--      1587  Oct 25 13:58 C++2LaTeX-1.1-patch#4
      FILE      rw-r--r--      8869  Mar 22 16:23 C++2LaTeX-1.1-patch#5
      FILE      rw-r--r--      1869  Mar 22 16:23 C++2LaTeX.README
Host rusmv1.rus.uni-stuttgart.de   ( Last updated 05:13 13 Apr 1991
    Location: /soft/tex/utilities
      FILE      rw-rw-r--    163840  Jul 16  1990   C++2LaTeX-1.1.tar

Q137: Where can I access `tgrind', a pretty printer for C++/C/etc source?
A: `tgrind' reads the file to be printed and a command line switch to see what
the source language is.  It then reads a language definition database file and
learns the syntax of the language (list of keywords, literal string delimiters,
comment delimiters, etc).

`tgrind' usually comes with the public distribution of TeX and LaTeX.  Look in
the directory:

A more up-to-date version of tgrind by Jerry Leichter can be found on:
	venus.ycc.yale.edu in [.TGRIND]

Q138: Is there a C++-mode for GNU emacs?  If so, where can I get it?
A: Yes, there is a C++-mode for GNU emacs.  You can get it via:

c++-mode-2 (1.0)  87-12-08
     Bruce Eckel,Thomas Keffer, 

     Another C++ major mode.
c++-mode	  89-11-07
     Dave Detlefs, et al, 

     C++ major mode.
c++		  90-02-01
     David Detlefs, Stewart Clamen, 
     C++ code editing commands for Emacs

c-support (46)	  89-11-04
     Lynn Slater, 
     Partial support for team C/C++ development.

Q139: What is `InterViews'?
A: A non-proprietary toolkit for graphic user interface programming in C++,
developed by Mark Linton and others when he was at Stanford.  Unlike C++
wrappers for C libraries such as Motif, InterViews is a true object library.
Commercially maintained versions are available from Quest, while freely
redistributable versions (running on top of X) from interviews.stanford.edu (an
ftp site).  Copies of this are (were?) distributed with the regular X
distribution.  Other sources of information include comp.windows.interviews,
which has its own FAQ.

Q140: Where can I get OS-specific questions answered (ex:BC++,DOS,Windows,etc)?
A: see comp.os.msdos.programmer, BC++ and Zortech mailing lists, BC++ and
   Zortech bug lists, comp.windows.ms.programmer, comp.unix.programmer, etc.

You can subscribe to the BC++ mailing list by sending email to:
|	To: listserv@ucf1vm.cc.ucf.edu   <---or LISTSERV@UCF1VM.BITNET
|	Subject: SUB TCPLUS-L
|	Reply-to: you@your.email.addr    <---ie: put your return address here

The BC++ bug report is available via anonymous ftp from sun.soe.clarkson.edu
[] from the file ~ftp/pub/Turbo-C++/bug-report
(also, I post it on comp.lang.c++ on the first each month).

Relevant email addresses:
	ztc-list@zortech.com          General requests and discussion
	ztc-list-request@zortech.com  Requests to be added to ztc-list
	ztc-bugs@zortech.com          For _short_ bug reports

Q141: Why does my DOS C++ program says `Sorry: floating point code not linked'?
A: The compiler attempts to save space in the executable by not including the
float-to-string format conversion routines unless they are necessary, and
sometimes does not recognize some code that does require it. Taking the address
of a float in an argument list of a function call seems to trigger it, but
taking the address of a float element of a struct may fool the compiler.  A
"%f" in a printf/scanf format string doesn't trigger it because format strings
aren't examined at compile-time.

You can fix it by (1) using  instead of , or (2) by
including the following function definition somewhere in your compilation (but
don't call it!):
	static void dummyfloat(float *x) { float y; dummyfloat(&y); }

See question on stream I/O for more reasons to use  vs .