Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I basically just want to know how to pass arrays into parameters of type char, F

ID: 3632167 • Letter: I

Question

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 .

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 definition 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:
[code]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;

and in the implementation:

Phonecall::Phonecall(): number(" "), length(0), rate(0)
{
}
PhoneCall::Phonecall(char num[10]): number{num[10]),length(0), rate(0)
{
}

and in the main function when declaring an object: (The overloaded constructor is used)

phonecall obj({1,2,3,4,5,6}); Is this example correct to change the c_string number in the private member of the class?

Explanation / Answer

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;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote