944,074 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1638
  • C++ RSS
May 19th, 2005
0

c++ help

Expand Post »
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

.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
cspikes is offline Offline
3 posts
since May 2005
May 19th, 2005
0

Re: c++ help

Please read the Announcement.
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
May 19th, 2005
0

Re: c++ help

Fill in the blanks:
C++ Syntax (Toggle Plain Text)
  1. class Entry {
  2. char _name[41]; // +1 for '\0'
  3. char _number[7]; // Not including format characters
  4. public:
  5. Entry(const char *name, const char *number);
  6.  
  7. void reset(const char *name, const char *number);
  8.  
  9. const char *name() const { /* ... */ }
  10. const char *number() const { /* ... */ }
  11. };
  12.  
  13. Entry::Entry(const char *name, const char *number)
  14. {
  15. // ...
  16. }
  17.  
  18. void Entry::reset(const char *name, const char *number)
  19. {
  20. // ...
  21. }
Reputation Points: 35
Solved Threads: 3
Posting Whiz in Training
Dogtree is offline Offline
232 posts
since May 2005
May 19th, 2005
0

Re: c++ help

(Dogtree, shouldn't the phone number be at least 8 for null terminator? (Probably actually 11 to include area code + null term)
Reputation Points: 68
Solved Threads: 18
Posting Pro in Training
winbatch is offline Offline
466 posts
since Feb 2005
May 19th, 2005
0

Re: c++ help

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.
Reputation Points: 35
Solved Threads: 3
Posting Whiz in Training
Dogtree is offline Offline
232 posts
since May 2005
May 19th, 2005
0

Re: c++ help

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).
Reputation Points: 10
Solved Threads: 0
Newbie Poster
cspikes is offline Offline
3 posts
since May 2005
May 19th, 2005
0

Re: c++ help

Quote ...
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?
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
May 20th, 2005
0

Re: c++ help

No, but I'm trying to figure it all out, by 009:00 hours.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
cspikes is offline Offline
3 posts
since May 2005
May 20th, 2005
0

Re: c++ help

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:
C++ Syntax (Toggle Plain Text)
  1. enum Suit { Hearts, Diamonds, Clubs, Spades };
And an integral face value is as simple as declaring an int:
C++ Syntax (Toggle Plain Text)
  1. int value;
Reputation Points: 35
Solved Threads: 3
Posting Whiz in Training
Dogtree is offline Offline
232 posts
since May 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: code help
Next Thread in C++ Forum Timeline: Creating Dialog Based Application without MFC





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC