kaktus9
March 30th, 2011, 06:43 PM
hello i'm writing some module for my program computing infix notation equasions
#include <iostream> //I/O
#include <stdexcept> //errory-gdyby trzeba było wywołać funkcję abort();
//debug purposes only
#include <string>//te 3 dla strlen
#include <sstream>
#include <cstring>
#include <math.h> //dla % dla liczb double bo by nie poszło as is d1%d2
int gn=0;
int go=0;
class yard{
public:
stack<double> number; //stos danych liczbowych
stack<string> oper; //stos operatorów
///////////////////
double inf_minus(double d1,double d2)//;
{
return -d1; //zwracanie liczby ze znakiem -
}
double inf_porownaj(double d1,double d2){
return d2<0 ? 0 : (d2==0?1:d1*inf_porownaj(d1, d2-1)); //powownanie liczb do 0 i przez wskaznik
}
double inf_mno(double d1,double d2){
return d1*d2; //mnozenie
}
double inf_dziel(double d1,double d2){
if(!d2){ //jesli mianownik nie !=0
cerr <<"0-HALT!"<<endl;
abort();
}
return d1/d2; //jak mianownik nie 0 to normalnie dzielimy
}
double inf_dodaj(double d1, double d2){
return d1+d2;
}
double inf_odejmij(double d1, double d2){
return d1-d2;
}
double inf_modulo(double d1, double d2)
{
if(!d2) {
cerr<<"0-HALT!"<<endl;
abort();
}
return modf(d1,&d2); //modulo specjalizowane-d1%d2 nie dziala
}
enum {none=0,left,prawa}; //typ wyliczeniowy dla kolejnosci dzialan/operatorow start od 0-nawias left- operator [lewostronny] prawa-operand dla "biegu wstecznego" [rewers znaku]
struct operacje{
char op; //operator
//teraz numerycznie
double prec;
double prd;
double bin;
double (*inf)(double d1, double d2);
}
ops[]{
{'_', 10, prawa, 1, inf_minus},
{'^', 9, prawa, 0, inf_porownaj},
{'*', 8, left, 0, inf_mno},
{'/', 8, left, 0, inf_dziel},
{'%', 8, left, 0, inf_modulo},
{'+', 5, left, 0, inf_dodaj},
{'-', 5, left, 0, inf_odejmij},
{'(', 0, none, 0, NULL},
{')', 0, none, 0, NULL}
};
......
};
in line 66 i'm getting the function definition does not declare parameters error
this bit:
ops[]{
{'_', 10, prawa, 1, inf_minus},
{'^', 9, prawa, 0, inf_porownaj},
{'*', 8, left, 0, inf_mno},
{'/', 8, left, 0, inf_dziel},
{'%', 8, left, 0, inf_modulo},
{'+', 5, left, 0, inf_dodaj},
{'-', 5, left, 0, inf_odejmij},
{'(', 0, none, 0, NULL},
{')', 0, none, 0, NULL}
};
it was working as C and now as C++ it's not
assist please
#include <iostream> //I/O
#include <stdexcept> //errory-gdyby trzeba było wywołać funkcję abort();
//debug purposes only
#include <string>//te 3 dla strlen
#include <sstream>
#include <cstring>
#include <math.h> //dla % dla liczb double bo by nie poszło as is d1%d2
int gn=0;
int go=0;
class yard{
public:
stack<double> number; //stos danych liczbowych
stack<string> oper; //stos operatorów
///////////////////
double inf_minus(double d1,double d2)//;
{
return -d1; //zwracanie liczby ze znakiem -
}
double inf_porownaj(double d1,double d2){
return d2<0 ? 0 : (d2==0?1:d1*inf_porownaj(d1, d2-1)); //powownanie liczb do 0 i przez wskaznik
}
double inf_mno(double d1,double d2){
return d1*d2; //mnozenie
}
double inf_dziel(double d1,double d2){
if(!d2){ //jesli mianownik nie !=0
cerr <<"0-HALT!"<<endl;
abort();
}
return d1/d2; //jak mianownik nie 0 to normalnie dzielimy
}
double inf_dodaj(double d1, double d2){
return d1+d2;
}
double inf_odejmij(double d1, double d2){
return d1-d2;
}
double inf_modulo(double d1, double d2)
{
if(!d2) {
cerr<<"0-HALT!"<<endl;
abort();
}
return modf(d1,&d2); //modulo specjalizowane-d1%d2 nie dziala
}
enum {none=0,left,prawa}; //typ wyliczeniowy dla kolejnosci dzialan/operatorow start od 0-nawias left- operator [lewostronny] prawa-operand dla "biegu wstecznego" [rewers znaku]
struct operacje{
char op; //operator
//teraz numerycznie
double prec;
double prd;
double bin;
double (*inf)(double d1, double d2);
}
ops[]{
{'_', 10, prawa, 1, inf_minus},
{'^', 9, prawa, 0, inf_porownaj},
{'*', 8, left, 0, inf_mno},
{'/', 8, left, 0, inf_dziel},
{'%', 8, left, 0, inf_modulo},
{'+', 5, left, 0, inf_dodaj},
{'-', 5, left, 0, inf_odejmij},
{'(', 0, none, 0, NULL},
{')', 0, none, 0, NULL}
};
......
};
in line 66 i'm getting the function definition does not declare parameters error
this bit:
ops[]{
{'_', 10, prawa, 1, inf_minus},
{'^', 9, prawa, 0, inf_porownaj},
{'*', 8, left, 0, inf_mno},
{'/', 8, left, 0, inf_dziel},
{'%', 8, left, 0, inf_modulo},
{'+', 5, left, 0, inf_dodaj},
{'-', 5, left, 0, inf_odejmij},
{'(', 0, none, 0, NULL},
{')', 0, none, 0, NULL}
};
it was working as C and now as C++ it's not
assist please