I am somewhat new to C++, so please forgive my ignorance. I have an assignment that I am working on and while I do not want someone to do my homework for me, some advice to point me in the right direction would be helpful.
I have a Class CProduct that contains two private members of type string( we will say stringA and stringB).
I am supposed to create an array of CProduct objects and then create two arrays of pointers to point to the each CProduct within the array.
I have been able to get this far.
My next task is to then rearrange the pointers in each array so that one array is has the pointers in the alpabetical order according to the CProduct.stringA it points to. The second pointer array needs to be reordered so that its pointers are in the alphabetical order according to the CProduct.stringB it points to.
The problem is that stringA and stringB are both private members of CProduct.
Unfortunatley I have spent 3 days searching through books, and the net to find a solution, other than either making stringA and stringB public or using accessor functions.(niether of which is an option for this assignment)
As mentioned this is an assignment, but my prof has gone to India for 2 weeks mid semester, and this is due when she gets back. I am not looking for the complete answer, but some suggestions to get me going in the right direction
I have included the code for my CProduct Class below:
Expand|Select|Wrap|Line Numbers
- #ifndef CPRODUCT_H
- #define CPRODUCT_H
- #include"MyString.h"
- #include <iostream>
- using namespace std;
- class CProduct
- {
- public:
- CProduct();
- CProduct(const MyString prodName_in, const MyString prodID_in, const int prodCategory_in, const double prodDetails_in[]);
- CProduct(const CProduct &productRHS);
- ~CProduct();
- CProduct &operator = (const CProduct &productRHS);
- friend istream &operator >> (istream &inStream, CProduct &productRHS);
- friend ostream &operator << (ostream &outStream, const CProduct &productRHS);
- static int Count();
- private:
- MyString prodName;
- MyString prodID;
- int prodCategory;
- double prodDetails[5];
- void errorCheck();
- static int cnt;
- static void DecProd();
- static void IncProd();
- };
- #endif //CPRODCUT_H
Any insights would be greatly appreciated.
Thank you in advance