And I need to validate that the first and second digits of each phone number are non-zero, that each phone number is 12 digits long, and then store them into an array in a class instance.
ie, when I do Contact someContact("John Doe", phoneNumbers, 7);, it'll create an instance someContact, and store ONLY VALID phone numbers in that instance.
My class is
1 2 3 4 5 6 7 8 9
class Contact {
char name[20];
int* m_pNumber;
short amtNumbers;
public:
Contact();
Contact(constchar* tempName, constint* tempNumber, short amount);
~Contact();
int validNumbers(constint* array, int count);
My default constructor should do this. I have defined my ctor as,
1 2 3 4 5 6 7 8 9 10
Contact::Contact(constchar* tempName, constint* tempNumber, short amount) {
for (int i = 0; i < 20; i++) {
name[i] = tempName[i];
}
int valids = validNumbers(tempNumber, amount);
m_pNumber = newint[valids];
for (int i = 0; i < valids; i++) {
m_pNumber[i] = tempNumber[i];
}
}
And my validNumbers() is where Im stuck. I started off defining it as
1 2 3 4 5 6
int validNumbers(constint* array, int count) {
int valid = count; //I plan on decrementing 'valid' for every invalid phone number
for (int i = 0; i < count; i++) {
//do something
}