-1

I am working on the eclipse (kepler) on C++11 and am required to use pow on a complex number (std::complex), but I get the following

error: template std::complex<_Tp> std::polar(const _Tp&, const _Tp&)

int Group::getActivity() const{
    complex<int> c(this->getNum1(), this->getNum2());
    c = pow(c, 3); //<--problem here
    return abs(c);
}

the code itself doesn't have an error in this function but I get an overall error about it (this is the only use of complex in the entire code and I'm required to use it)

Just to be clear, I'm using std::complex and there is an include line at the beginning of the cpp file.

Praetorian
  • 106,671
  • 19
  • 240
  • 328
AdiA92
  • 11
  • 3
  • 2
    What does this mean - *the code itself doesn't have an error in this function but I get an overall error*? Does the code compile, but you're seeing red lines under that line from Eclipse's static code analyzer? If it's the latter, try googling *eclipse code analyzer c++11* or *eclipse codan c++11*. There are several questions on StackOverflow asking about that too. If that is indeed the problem, you may even want to consider ignoring the red lines. – Praetorian Jun 22 '14 at 19:31
  • it means that the project is built and there are no red lines anywhere but I get an error in the error window (and about 5 infos about it) – AdiA92 Jun 22 '14 at 20:03
  • If compilation is successful, then it must be the code analyzer showing those error messages. Try the suggestions from my previous comment. – Praetorian Jun 22 '14 at 20:08
  • 2
    "...about 5 info's about it"? yet you only posted *one* of them? The remaining "infos" likely elaborate on the line you chose to post here. Post *those* as well. – WhozCraig Jun 22 '14 at 20:14
  • I posted only the error, not the infos. they where just fractures of the error and didn't really say anything, stuff like "reacquired from here", all just pointed to the same line – AdiA92 Jun 23 '14 at 20:24

1 Answers1

0

Does it work if you change int to double? The complex template is only meant to be used with floating point types (float, double, long double). I would suspect that this is the problem.

(This question has some authoritative links on the subject.)

Community
  • 1
  • 1
sfjac
  • 7,119
  • 5
  • 45
  • 69