Delam to v Netbeansech a cekal jsem, ze tohle tam maj poreseny, kdyz to dam prelozit z konsole tak to facha...
Příspěvky odeslané z IP adresy 95.85.240.–
Ahoj mam problem s nasledujicim kodem:
#include <math.h>
int main(int argc, char** argv) {
double radians = 45 * M_PI / 180;
double result;
result = cos(radians);
return (0);
}
Hazi to chybu: main.c:12: undefined reference to `cos'
pokud to prepisu na napr:
result = cos(1.0);
tak vse funguje. Co s tim proboha je???
Diky, jeste bych se chtel zeptat, proc nefunguje nasledujici kod:
int main(int argc, char** argv) {
vector<int>::pointer v = new vector<int>;
v->push_back(2);
for(int i=0; i < v->size(); i++){
cout << (*v)[i] << endl;
}
delete v;
return 0;
}
Chyby pri prekladu:
main.cc:28:34: error: cannot convert ‘std::vector<int>*’ to ‘int*’ in initialization
main.cc:30:8: error: request for member ‘push_back’ in ‘* v’, which is of non-class type ‘int’
main.cc:32:25: error: request for member ‘size’ in ‘* v’, which is of non-class type ‘int’
main.cc:33:24: error: invalid types ‘int[int]’ for array subscript
Diky
Mam nasledujici kod:
int main(int argc, char** argv) {
//vector<int>::pointer v = new vector<int>;
vector<int>* v = new vector<int>;
for(int i=0; i < v->size(); i++){
cout << (int) v[i] << endl;
}
return 0;
}
ktery mi hazi chybu:
main.cc:33:26: error: invalid cast from type ‘std::vector<int>’ to type ‘int’
Nevite co je za problem? A proc existuje neco jako vector<int>::pointer a jak se to lisi od "normalnikho" pointeru. Diky.