### how to fix?

i compiled my program and it says --> name lookup of 'v' changed for ISO 'for' scoping [-fpermissive]. what does it mean?

and no matching function for call to 'PolynomialClass::PolynomialClass(int*&, const int&)' i declared it in the public, so i dont know how to fix this.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180`` ``````#include #include #include #include using namespace std; class PolynomialClass { public: PolynomialClass(); PolynomialClass (double *pD2, int newExp); PolynomialClass(PolynomialClass&); void output(void); ~PolynomialClass(); PolynomialClass operator +(PolynomialClass L); PolynomialClass operator -(PolynomialClass L); PolynomialClass operator *(PolynomialClass L); PolynomialClass operator /(PolynomialClass L); friend ostream& operator << (ostream&strm, const PolynomialClass); private: double *pDouble; int Exp; }; PolynomialClass::PolynomialClass() { Exp = 0; pDouble = new double[Exp + 1]; pDouble[0] = 0; } PolynomialClass::PolynomialClass(PolynomialClass& copy) { Exp=copy.Exp; copy.pDouble = new double [copy.Exp + 1]; for (int i = 0; i < copy.Exp; i++) this->pDouble[i] = copy.pDouble[i]; this->Exp = copy.Exp; } PolynomialClass:: PolynomialClass(double *pD2, int newExp) { Exp=newExp; pDouble = new double[newExp+1]; for (int c = newExp; newExp>=0; c--) } PolynomialClass PolynomialClass:: operator +(PolynomialClass L) { PolynomialClass plus; plus.pDouble = new double [this->Exp+1]; for (int m=this->Exp; m>=0; m--) { plus.pDouble[m]=pDouble[m]+ L.pDouble[m]; plus.Exp= this->Exp; } return plus; } PolynomialClass PolynomialClass:: operator -(PolynomialClass L) { PolynomialClass minus; minus.pDouble= new double [this->Exp+1]; for (int m=this->Exp; m>=0; m--) { minus.pDouble[m]=pDouble[m]- L.pDouble[m]; minus.Exp= this->Exp; } return minus; } PolynomialClass PolynomialClass:: operator *(PolynomialClass L) { PolynomialClass times; int Exp= (this->Exp + L.Exp+1); times.Exp = (Exp + L.Exp); for( int m = 0; m <= Exp; m++ ) for( int j = 0; j <= L.Exp; j++ ) times.pDouble[ m + j ] = pDouble[ m ] *L.pDouble[ j ]; return times; } PolynomialClass PolynomialClass:: operator /(const PolynomialClass L) { PolynomialClass divide; int Exp= (Exp- L.Exp+1); divide.Exp = (Exp - L.Exp); for( int m = 0; m <= Exp; m++ ) for( int j = 0; j <= L.Exp; j++ ) divide.pDouble[ m - j ] = pDouble[ m ] / L.pDouble[ j ]; return divide; } void PolynomialClass::output(void) { for(int p=Exp; p>0; p--) cout <> ExpA; polyA= new int[ExpA+1]; for (int v = ExpA; v>=0; v--); { cout << "input coefficient of x^ " << v <<":"; //this is the problem; it says name lookup of 'v' changed for ISO 'for' scoping [-fpermissive]. cin >> polyA[v]; } const int NewExpA=ExpA; int *polyB, ExpB; cout <<"Input degree of poly2:"; cin >> ExpB; polyB= new int[ExpB+1]; for (int w = ExpB; w>=0; w--); { cout << "input coefficient of x^" << w << ":"; //this is the problem; name lookup of 'w' changed for ISO 'for' scoping [-fpermissive]. cin >> polyB[w]; } const int NewExpB=ExpB; PolynomialClass C (double polyA, int newExpA); //this is the problem PolynomialClass D (double polyB, int newExpB); //this is the problem cout<<"polynomial A is "; C.output(); cout<
Last edited on
The translation of the first error is "v was not declared in this scope".
The second error is self-evident, just read what it says.
thank you! :)
Topic archived. No new replies allowed.