Incompatible issue (version 2.95 and 3.3) when using template

P

PengYu.UT

Hi All,

I compiled the following program by both g++ 2.95.4 and g++ 3.3. But
they gave me different results. g++ 3.3 said there are some errors. Do
you know what is wrong with the program?

Thanks,
Peng

$ g++ --version
2.95.4
$ g++ -o test test.cc
$ g++-3.3 --version
g++-3.3 (GCC) 3.3.3 20040110 (prerelease) (Debian)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

$ g++-3.3 -o test test.cc
test.cc:6: error: parse error before `<' token
test.cc:9: error: `_Tp' was not declared in this scope
test.cc:9: error: syntax error before `operator'
$


#include <functional>
#include <complex>
#include <cmath>

template <class _Tp>
class scrJ_minus_O : public binary_function<_Tp, _Tp, complex<_Tp> >{
public:
scrJ_minus_O(const _Tp& sigma) : _sigma_times_sigma(sigma * sigma)
{};
complex<_Tp> operator()(const _Tp& f, const _Tp& g){
if((f * f + g * g) < _sigma_times_sigma)
return 1. / (M_PI * _sigma_times_sigma);
else
return 0.;
}
private:
_Tp _sigma_times_sigma;
};

int main(int argc, char *argv[]){
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,815
Messages
2,569,702
Members
45,492
Latest member
juliuscaesar

Latest Threads

Top