By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,402 Members | 1,017 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,402 IT Pros & Developers. It's quick & easy.

Incompatible issue (version 2.95 and 3.3) when using template

P: n/a
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[]){
}

Jul 23 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.