c++ help

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: May 2005
Posts: 3
Reputation: cspikes is an unknown quantity at this point 
Solved Threads: 0
cspikes cspikes is offline Offline
Newbie Poster

c++ help

 
0
  #1
May 19th, 2005
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

.
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,461
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 254
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: c++ help

 
0
  #2
May 19th, 2005
Please read the Announcement.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 232
Reputation: Dogtree is an unknown quantity at this point 
Solved Threads: 3
Dogtree's Avatar
Dogtree Dogtree is offline Offline
Posting Whiz in Training

Re: c++ help

 
0
  #3
May 19th, 2005
Fill in the blanks:
  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. }
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 466
Reputation: winbatch is on a distinguished road 
Solved Threads: 18
winbatch's Avatar
winbatch winbatch is offline Offline
Posting Pro in Training

Re: c++ help

 
0
  #4
May 19th, 2005
(Dogtree, shouldn't the phone number be at least 8 for null terminator? (Probably actually 11 to include area code + null term)
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 232
Reputation: Dogtree is an unknown quantity at this point 
Solved Threads: 3
Dogtree's Avatar
Dogtree Dogtree is offline Offline
Posting Whiz in Training

Re: c++ help

 
0
  #5
May 19th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 3
Reputation: cspikes is an unknown quantity at this point 
Solved Threads: 0
cspikes cspikes is offline Offline
Newbie Poster

Re: c++ help

 
0
  #6
May 19th, 2005
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).
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,461
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 254
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: c++ help

 
0
  #7
May 19th, 2005
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?
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 3
Reputation: cspikes is an unknown quantity at this point 
Solved Threads: 0
cspikes cspikes is offline Offline
Newbie Poster

Re: c++ help

 
0
  #8
May 20th, 2005
No, but I'm trying to figure it all out, by 009:00 hours.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 232
Reputation: Dogtree is an unknown quantity at this point 
Solved Threads: 3
Dogtree's Avatar
Dogtree Dogtree is offline Offline
Posting Whiz in Training

Re: c++ help

 
0
  #9
May 20th, 2005
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:
  1. enum Suit { Hearts, Diamonds, Clubs, Spades };
And an integral face value is as simple as declaring an int:
  1. int value;
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum


Views: 1524 | Replies: 8
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC