0

I am a new c++ student trying to write code....please help.....
I have a telephone entry
Name has at most 40 charachters
Seven digit number
I want to be able to tell the number, name and reset name for name changes and reset the # if a person moves

.

4
Contributors
8
Replies
9
Views
11 Years
Discussion Span
Last Post by Dogtree
0

Fill in the blanks:

class Entry {
  char _name[41];  // +1 for '\0'
  char _number[7]; // Not including format characters
public:
  Entry(const char *name, const char *number);

  void reset(const char *name, const char *number);

  const char *name() const { /* ... */ }
  const char *number() const { /* ... */ }
};

Entry::Entry(const char *name, const char *number)
{
  // ...
}

void Entry::reset(const char *name, const char *number)
{
  // ...
}
0

(Dogtree, shouldn't the phone number be at least 8 for null terminator? (Probably actually 11 to include area code + null term)

0

It depends on the implementation; it could go either way. If no formatting information is included then there'll probably be a method to print the number and add formatting. If that's the case then the only purpose of a null character is to act as a sentinel. But if the size is always 7, there's no reason to use a sentinel such as with the name where it could be any amount up to 40 characters. As for area code, yea, I'd probably include space for that or have a separate member[*], but cspikes made it clear that the phone number was 7 characters.


[*] Actually, I'd be a lot more lenient in how phone numbers are set up for internationalization purposes. Most likely I'd write a facet to handle phone numbers and set up the data accordingly. But that's way beyond the scope of this thread, so I didn't mention it. ;)

0

I am a c++ student for the first time and need some help :( :o
Cards_suffle:: deck ( int suffle, float deal, int dealt)

{

cards_ shuffle_ = s;

cards_ deal_ = d;

cards_ dealt_ = d;

}

the code I am trying to write is for:

An ordinary playing card. The cards are identified by suit (club, diamonds, hearts, spade) and face value (ace, two, three, . . . . jack, queen, king). To represent the suit type, make an enumeration definition before making the struct definition of the card. Make the face values integers (1 through 13).

0

To represent the suit type, make an enumeration definition before making the struct definition of the card. Make the face values integers (1 through 13).

Have you done any of this?

0

No, but I'm trying to figure it all out, by 009:00 hours. :( :?: :?:

0

No offense, but if you're so pressed for time on something this simple, you probably deserve a failing grade. That said, enumerations are easy to define:

enum Suit { Hearts, Diamonds, Clubs, Spades };

And an integral face value is as simple as declaring an int:

int value;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.