Hi all!
I was just wondering if anyone could figure out why this won't compile... I grant you main does nothing right now, but the code should still compile (I think!)
For every class member function, I get the error (where <class is the class name): <class> followed by 'int' is illegal (did you forget a ';'?)
Here's the code:
Code:#include <iostream.h> #include <string.h> #include <stdlib.h> #include <math.h> class number { private: int value; public: int returnnumber(); int enternumber(int); } int number::returnnumber() { return value; } int number::enternumber(int enter) { value = enter; } class hexa { public: int input(); int displayhex(int) } int hexa::input() { int num; cout << "Enter a hex number: "; cin >> hex >> num; return num; } int hexa::displayhex(int disp) { cout << "Hex: " << hex << disp; } class octal { public: int input(); int displayoct(int); } int octal::input() { int num; cout << "Entre an octal number: "; cin >> oct >> num; return num; } int octal::displayoct(int disp) { cout << "Oct: " << oct << disp; } class binary { public: int input(); int displaybin(int); } int binary::input() { int a=0; int b=0; int power; int dec=0; char str[100]; for (a=0;a<100;a++) { str[a] = '\0'; } cin.getline(str, 100); while (str[b] != '\0') { b++; } b -= 1; for (a=0;a<=b;a++) { power = b - a; if (str[a] == '1') { dec += pow(2, power); } } return dec; } int bin::displaybin(int dec) { int a=0; while (dec != 0) { if (dec % 2 == 1) { str[a] = '1'; } else { str[a] = '0'; } dec = dec / 2; a++; } for (a;a>=0;a--) { cout << str[a]; } } int main(void) { return 0; }