+ 1
#include <iostream> using namespace std; class employee int main() { private: double salary; public: void getsalary(double sal) { salary=sal; } void display() { cout<<"the salary:"<<salary; } }; void main () { employee programmer; employee manager; manager.getsalary (60000.0); programmer.getsalary(40000.0); manager.display(); programmer.display(); return 0; }
please correct it plz
5 Réponses
+ 3
u cannot have more than one main function in ur program
0
the first main isnt needed. The second one is supposed to be int main not void.
0
Instead of void main() use int main ()
or remove the return 0.
The program will not show any error, try it
0
You unexpectedly put int main() before the bracket which was meant for the opening of class employee.
0
I'm not sure if you meant "setSalary"... "get" functions should never be "void", they should always return what you're trying to get.
Void Main should not return anything. you can use "void main" but if you do, do not return 0, it is a void function, there should be no return type.
edit: and like the above commenter said, there should be only be one main.