Error in constructor

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <complex>
complex<double> max (complex <double> * array,int numberofelements)throw(std::string){
    if (numberofelements < 1 || numberofelements > INT_MAX){
        throw std::string ("Error too few values in max array");
    }
    complex <double> returncomp=array[0]
    for (int i=0;i<functionlength;i++){
        if (array[i].real()>returncomp.real()){
            returncomp = (array[i].real,returncomp.imag);
        }
        if (array[i].imag()>returncomp.imag()){
            returncomp = (returncomp.real,array[i].imag);
        }
    }
    return returncomp;
}


Error- error: expected constructor, destructor, or type conversion before '<' token

This is particularly frustrating atm because I have tried all that I can think of as a fix. Complex has to have <double> or an equivalent type declared in the constructor. Also, I have built a function just like this elsewhere and received no errors.

Any advice would be amazing.

Also, if there are problems in certain parts of the code that are not the error (i.e. lack of ->) don't worry too much about it plz.
Last edited on
is this std::complex?

try putting std:: before every complex.

Also you're missing a semicolon on line 5.
ah thank you.

Also you're missing a semicolon on line 5.


also missing some parens in there too. :)
Topic archived. No new replies allowed.