#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; } | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

28th Jun 2016, 9:14 AM
Rojin Bastola
Rojin Bastola - avatar
5 Answers
+ 3
u cannot have more than one main function in ur program
1st Jul 2016, 9:21 AM
Jay
Jay - avatar
0
the first main isnt needed. The second one is supposed to be int main not void.
28th Jun 2016, 9:20 AM
Armandas Bolevičius
Armandas Bolevičius - avatar
0
Instead of void main() use int main () or remove the return 0. The program will not show any error, try it
28th Jun 2016, 11:09 AM
Jay Thakur
Jay Thakur - avatar
0
You unexpectedly put int main() before the bracket which was meant for the opening of class employee.
28th Jun 2016, 1:44 PM
_Geometry dash_ _Roh_ (AKA NovaRate0315)
_Geometry dash_ _Roh_ (AKA NovaRate0315) - avatar
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.
19th Jul 2016, 9:55 AM
maz