I basically just want to know how to pass arrays into parameters of type char, For example my question is to implement and define a function of type char in a class (The underlined part the is the main question, the bold part is my answer.
Define a class PhoneCall that represents a phone call. This class has three member variables:
• number, a C-string that holds the phone number (consisting of 10 digits) to which a call is placed
• length, an int representing the length of the call in minutes
• rate, a float representing the rate charged per minute.
In my class defintion i must have: • A default constructor that initializes number to an empty string, length to 0 and rate to 0.
• An overloaded constructor that accepts a new phone number and sets length and rate both to 0.
I want to know if this is correct:
1 2 3 4 5 6 7 8 9
class phonecall
{
public:
PhoneCall();
Phonecall(char num[10])//Is this correct?private:
char number;//Is this correct or must it be char number[10]; ?
string contact;
string type;
class phonecall
{
public:
PhoneCall();
Phonecall(char *num) //Is this correct?
private:
char *number; //Is this correct or must it be char number[10]; ?
string contact;
string type;
A pointer can be used to access the elements of an array.