delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/05/22/16:18:24

Date: Mon, 22 May 95 14:44:53 CDT
From: m-fuerst <m-fuerst AT cecer DOT army DOT mil> (Michael J Fuerst)
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Templates, and static ptrs to functions

************************
Problem 1
************************

I have a template class Base2Array with a Base2Array.h and 
a Base2Array.cxx file.

The class has a public static member compare_s, declared in
Base2Array.h.   (Note: Boolean is a synonym for int)

  template<class Type>
  class Base2Array: public BaseArray {
    .
    .
    static Boolean (*compare_s)(const Type& t1, const Type& t2);
    .
    .
  }

The Base2Array.cxx (in addition to much other stuff) contains
the following:

  template<class Type>
  Boolean is_data_equal (const Type& t1, const Type& t2) {
	return (t1 == t2);
  }

  // compare_s -- static data member of Base2Array, 
  //              pointer to operator== for Type
  template<class Type>
  Boolean (*Base2Array<Type>::compare_s)(const Type&, const Type&) = 
                is_data_equal;



DJGPP complains about this list statement with the message:

  invalid template:  
  'int (*compare_s)(<template type parm Type>&, <template type parm Type>&)' 

My reading of Lippman's text suggests my syntax is correct.
Borland C++ 3.1 accepts this (but I abandoned that compiler
since my class worked fine for int's but not for
floats or doubles.   

Any suggestions, or do I not really have the syntax right?


I'm using DJGPP ver 1.11.


***************
Problem 2
***************

How do I direct djgpp's compile and link error messages to 
a file, instead of to the screen?  




Thanks

Michael Fuerst
Construction Engineering Research Lab
Box 9005             Champaign IL 61826    USA                217-373-7273

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019