I have program on phone book. With the first class
class entry
{
string name;
int number;
...
}
With the 2nd class handling array of objects
class phoneBook
{
Entry objs[100];//maximum 100 users
//getter and setter below
...
}
I have main() function to control them.
int main(){
phoneBook p;
p.count(count);
p.add(count,name,number);
p.print();
...
}
My questions is with the line:
phoneBook p;
Each time I call this line, it will initialize the objs[100] in class phoneBook. Suppose I am imputing objs[2], my objs[1] will be empty then. How to fix my structure please?
intis not the right type for telephone numbers. Telephone numbers are strings of digits, not integer numbers. For example, in many parts of the world, most telephone numbers start with 0.phoneBook p;you are creating a new empty phone book. Are you creating a new phone book every time you add an entry?