| | |
c++ help
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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
Fill in the blanks:
C++ Syntax (Toggle Plain Text)
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) { // ... }
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.
[*] 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.
•
•
Join Date: May 2005
Posts: 3
Reputation:
Solved Threads: 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).
: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).
•
•
•
•
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).
"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
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:
And an integral face value is as simple as declaring an int:
C++ Syntax (Toggle Plain Text)
enum Suit { Hearts, Diamonds, Clubs, Spades };
C++ Syntax (Toggle Plain Text)
int value;
![]() |
Other Threads in the C++ Forum
- Previous Thread: code help
- Next Thread: Creating Dialog Based Application without MFC
Views: 1524 | Replies: 8
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api array arrays based beginner binary bmp c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete deploy dll download dynamic dynamiccharacterarray encryption error file format forms fstream function functions game givemetehcodez graph gui homeworkhelp iamthwee ifstream input int java lib library lines linker list loop looping loops map math matrix memory newbie news number output pointer problem program programming project python random read recursion recursive reference return rpg search simple sort spoonfeeding string strings struct temperature template templates text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






