| Woody1193 (17) | |||
|
So, I was building this code recently and I got some errors (seems obvious right, hold off on the sarcasm for awhile please). Anyway, the errors specifically were: packages.cpp:586:34: error: expected primary-expression before ‘;’ token packages.cpp:620:15: error: no match for ‘operator>>’ in ‘std::cin >> *(p + ((long unsigned int)(((long unsigned int)i) * 8ul)))’ packages.cpp:623:20: error: ‘getCharge’ was not declared in this scope I'm pretty sure the other two errors were caused by the same bug that caused the 2nd one but I'm not really sure why it's happening. Here's the offending code:
Any tips would be great if you've got them. | |||
|
Last edited on
|
|||
| Angeljruiz (167) | |
|
You probably didnt overload your package class Please use code tags tho, itd make it alot easier to read and you'd prolly get more answers faster | |
|
|
|
| Woody1193 (17) | |
| Ok, so forget about Error 3. That was a snafu in actually calling the function. | |
|
|
|
| TheJJJunk (181) | |
|
Error 2: you have p = new package[siNumPackages]*try p = new package*[siNumPackages] | |
|
Last edited on
|
|
| Woody1193 (17) | |
|
Thanks TheJJJunk. I'm implementing the solutions now. I'll tell you if it works. Angeljruiz, what do you mean by overloading the class? | |
|
Last edited on
|
|
| Woody1193 (17) | |
|
Well I fixed Error 2, it was as TheJJJunk pointed out. However, all the derived classes have been declared correctly as far as I can tell. | |
|
|
|
| Woody1193 (17) | |
Ok, I've fixed the issue. The problem was that my input operator functions for the derived and base classes were declared virtual (and therefore, couldn't be declared as friends). As such, the correct code would have been*p[i] >> cin;or something similar. Anyway, I un-virtualized the overloaded functions and made them friends and now the error is gone | |
|
|
|