Ok right I see what you mean Moschops. So if you see the whole code posted earlier is this the right direction to be going in having two classes, Shoe and Shoe_List? Are you saying I should do this for all my functions? I might be starting to confuse myself here
Sorry for the late reply but thanks for the help. Not sure if I should be posting on this thread again since it is quite old? But a question about the class Shoe that was initial posted on page 1. If the variables are private in Shoe how can I display shoes? If they are private and I do:
There's no need to be so blunt or arrogant; well that is how you are coming across to me anyway. Im here to learn after all. Maybe that should have been 'What ELSE would you suggest?' I'm not worrying about best practice I'm only asking since there is no harm in learning this along the way.
I have created a basic object oriented database of a list of shoes containing the shoe name, number and shoe size. I am trying to sort the list of shoes alphabetially by name and by shoe size. I have the following code:
using namespace std;
Shoe(string Name_, double ShoeSize_, int Number_);
string getName() const;
double getShoeSize() const;
int getNumber() const;
void setName(const string Name_);
void setShoeSize(const double ShoeSize_);
void setNumber(const int Number_);
int sortname(const void*, const void*);
int sortshoesize(const void*, const void*);
Shoe * shoes;
Didnt see that for the life of me! Thank you all for your help I have learnt a lot!
One last thing. If I am adding functions such as save would it be better code practice to pass the shoes array as const and also the length as call by value for the functions save and view since they shouldn't change for these functions? And then the opposite for functions that do want to change the shoes array and length? So:
//Functions that do not intend to change shoes and length
void Shoe_List::save(const Shoe * shoes, int length);
void Shoe_List::view(const Shoe * shoes, int length);
//Functions that do intend to change shoes and length
void Shoe_List::load(Shoe * shoes, int & length);
void Shoe_List::add(Shoe & shoes, int & length);
What are the advantages of using a vector over an array?
I don't really understand setters and getters...I haven't been taught to use this. Im not sure what exactly they are doing but I shall read up on them.
The only other problem is that it says length is undeclared when I add it as a variable to pass in the functions, which I dont understand as it is declared in the shoes class in Shoes.h :-S does anyone know why this is?