Ask your own question, for FREE!
Computer Science 13 Online
OpenStudy (anonymous):

C++ Help - How can i remove the class object from the following code? I wanna rewrite this code using only array. Please help! #include #include using namespace std; class Employee { private: int id; string name, designation; float salary; public: void getData() { cout << "--Enter Employee Data" << endl; cout << "ID? : "; cin >> id; cout << "Name? : "; cin >> name; http://paste.ubuntu.com/6998646/

OpenStudy (e.mccormick):

An array is an array of something. In this case you have an array of class objects. I am not sure what you mean because of this.

OpenStudy (anonymous):

I wanna rewrite this using only Array. Could you help?

OpenStudy (e.mccormick):

Look at all the data stored in the class. Write an array for each element in the class. So for each of these variables: int id; string name, designation; float salary; You need to make an array.

OpenStudy (anonymous):

You mean something like this: http://paste.ubuntu.com/7031685/ But i got so many errors. and its not working. Please help me out here. Thanks,

OpenStudy (anonymous):

I think associative arrays are implemented as maps in C++ http://www.cplusplus.com/reference/map/map/ With that you can store the values in an array with logical keys to reference them

OpenStudy (anonymous):

@seandisanti Thanks for your replay. I'm not a C++ programmer or something. I'm trying to help out someone. Can you please help me converting the first program with Array only. Please?...

OpenStudy (anonymous):

The first code this one => http://paste.ubuntu.com/6998646/ works fine. But i would like to have without class. Use only Array and strings. Please help..

OpenStudy (anonymous):

I'm actually already actively writing solutions to a problem set for someone else, and was just popping in to help out where a quick explanation would be help enough to get going the right direction. This one is a pretty easy issue, I promise, check out this example of map usage: http://www.yolinux.com/TUTORIALS/CppStlMultiMap.html

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!