| |
Giygas learns the art of C++
Lightning |
|

Ignorance isn't stupidity but choosing to remain ignorant is
![Super Happy Heart Badge [*]](https://archive.mfgg.net/html/badges/shappyheart.gif) ![MFGG Awards 2008 Winner [*]](https://archive.mfgg.net/html/badges/award08.gif)

Group: IRC Operators
Posts: 6381
Member No.: 583
Joined: 31-August 04
Status: (0d)
![[--]](style_images/mfgg2_skin/warn_nosuspend.gif)

|
yeah, you clearly understand flow control, basic arithmetic operations and input/output. go to the next concept now, and make something out of it too.
my recommendation: you've apparently got random down too, so when you get to arrays, see if you can figure out how to shuffle a deck of 52 cards and deal them out.
(oh, if you haven't already, figure out how to swap variables)
--------------------
click here to change my avatar. / gosh why are you even here lightninghacker, n.an individual who enjoys learning computer system details and how to capitalize on his or her capabilities...not a criminal. (from webster's new world hacker dictionary) |  Fedora 10 Final! Download today! | quality web comics (stories):- girl genius: adventure! romance! mad science!
- punch an' pie: try a slice of life, then swallow.
- dresden codak: most interesting comic ever
quality web comics (one-shots):- a softer world: truth and beauty bombs
- smbc: saturday morning breakfast cereal
- buttersafe: pictures and probably some words
|
"Religion is comparable to a childhood neurosis." - Sigmund Freud “It is not by delusion, however exalted, that mankind can prosper, but only by unswerving courage in the pursuit of truth.” - Bertrand Russell “To kill an error is as good a service as, and sometimes better than, the establishing of a new truth or fact.” - Charles Darwin
|
|
|
Xgoff |
|

<):|
![Super Happy Heart Badge [*]](https://archive.mfgg.net/html/badges/shappyheart.gif) ![Sprite Comp Winner Badge (1) [*]](https://archive.mfgg.net/html/badges/scg1.gif) ![Drawing Comp Winner Badge (1) [*]](https://archive.mfgg.net/html/badges/dcg1.gif) ![Drawing Comp Runner Up Badge (1) [*]](https://archive.mfgg.net/html/badges/dcr1.gif) ![MFGG Awards 2006 Winner [*]](https://archive.mfgg.net/html/badges/award06.gif)
![MFGG Awards 2007 Winner [*]](https://archive.mfgg.net/html/badges/award07.gif) ![Forum Event Badge [*]](https://archive.mfgg.net/html/badges/event.gif)

Group: Members
Posts: 52341
Member No.: 24
Joined: 13-October 03
Status: (0d)
![[--]](style_images/mfgg2_skin/warn_nosuspend.gif)

|
| QUOTE (Bacteriophage @ Sep 24 2009, 06:04 PM) | | also if you're going to use decimal numbers I personally suggest double. There's still inaccuracy but there's less of it. |
also floats don't support the full integer range that ints do (precision-wise); if you convert a float to an int you could potentially lose information
doubles not only have the full range but also an extra ~20 bits worth (if your ints are represented as 32-bits anyway), but of course are twice the size
| QUOTE | | int can do a lot of things that float can't. For example, an int number can be used as a counting number and be incremented/decremented as part of a for loop. |
i'm pretty sure floats and doubles can be used for this is well, but yeah precision conflicts will likely bite you if you try
--------------------
 DISCLAIMER: by sending me (xgoff) a private message, you agree to the directives and their terms specified henceforth: DIRECTIVE 1 (APPLE): i may or may not reply promptly or at all; and there are no guarantees to the usefulness of the reply. i may not acknowledge whether i have even received your private message DIRECTIVE 2 (CHILE CON CARNE): as per my view, "private" applies only to the initial transaction, and the material of your message may or may not be made public at my discretion; as this will more than likely be a post in the CCC or IRC, you may not be able to view it DIRECTIVE 3 (FEATHER DUSTER): you must address me (xgoff) as "Sir Master Xgofficus his Highest and Most Awesome the Third"; failure to comply with this term may invoke one or both of the above directives, and i will leave a burning bag of **** on your doorstep DIRECTIVE 4 (BOOTSTRAP): if you have read this disclaimer, please private message me promptly, in compliance with the above terms, so i can ensure you are capable of following directions you idiot this concludes the test of the emergency disclaimer system, your scheduled programming will now continue. satisfaction guaranteed, and 100% cash back available under certain circumstances; restrictions may or may not apply within your place of residence NOTICE: these directives and their terms may change at any time, without notice; as a private message transaction to myself assumes an understanding and full compliance of the above, you should ensure you are fully aware of the above terms at any point before sending a private message; any message received is assumed to have been sent in compliance with the above| QUOTE | (5:25:58 PM) Mikau: xgoff (5:26:00 PM) Mikau: guess what (5:26:04 PM) Xgoff: chicken butt (5:26:09 PM) Mikau: **** you |
|
|
|
Giygas |
|

Standard Member
![Happy Heart Badge [*]](https://archive.mfgg.net/html/badges/happyheart.gif)

Group: Members
Posts: 910
Member No.: 4767
Joined: 24-November 07
Status: (0d)
![[--]](style_images/mfgg2_skin/warn_nosuspend.gif)

|
| QUOTE (Lightning @ Sep 24 2009, 07:43 PM) | yeah, you clearly understand flow control, basic arithmetic operations and input/output. go to the next concept now, and make something out of it too.
my recommendation: you've apparently got random down too, so when you get to arrays, see if you can figure out how to shuffle a deck of 52 cards and deal them out.
(oh, if you haven't already, figure out how to swap variables) |
{Lightnings Seal of Approval}
Excellent, then- I guess my calculator is finished now ( Just added the function that clears the screen after you recieve your answer to avoid clutter ), so I guess I will be moving onto some slightly more advanced concepts.
More specificly, Control Structures and Functions.
Thanks for your support, guys- It really helps when other people know about it, or are learning to. :3.
This post has been edited by Giygas on Sep 24 2009, 07:47 PM
|
|
|
Giygas |
|

Standard Member
![Happy Heart Badge [*]](https://archive.mfgg.net/html/badges/happyheart.gif)

Group: Members
Posts: 910
Member No.: 4767
Joined: 24-November 07
Status: (0d)
![[--]](style_images/mfgg2_skin/warn_nosuspend.gif)

|
Looking through Structure, I realise that almost everything covered there was already present in my calculator, like if, else if, else, etc. And I am used to it. However, Functions I have not used in my calculator, or even used extensively. Because I only have Functions to work with to expand, I am not sure what tool I can create that uses alot of functions with differen't formats. Basiclly, a program that would show me how important functions can be in simple operations, and can get me used to using them, like the calculator did for input/output and commands.
|
|
|
Retriever II |
|

Catalyst
![Host Badge [H]](https://archive.mfgg.net/html/badges/host.gif) ![Big Help Badge [*]](https://archive.mfgg.net/html/badges/bighelp.gif) ![Ultra Happy Heart Badge [*]](https://archive.mfgg.net/html/badges/uhappyheart.gif) ![Super Submitter Badge [*]](https://archive.mfgg.net/html/badges/submissions.gif) ![Sprite Comp Winner Badge (2) [*]](https://archive.mfgg.net/html/badges/scg2.gif)
![Sprite Comp Top 5 Badge (2) [*]](https://archive.mfgg.net/html/badges/sct2.gif) ![MFGG Awards 2004 Winner [*]](https://archive.mfgg.net/html/badges/award04.gif) ![MFGG Awards 2005 Winner [*]](https://archive.mfgg.net/html/badges/award05.gif) ![MFGG Awards 2006 Winner [*]](https://archive.mfgg.net/html/badges/award06.gif) ![MFGG Awards 2007 Winner [*]](https://archive.mfgg.net/html/badges/award07.gif)

Group: Members
Posts: 18290
Member No.: 52
Joined: 13-October 03
Status: (0d)
![[--]](style_images/mfgg2_skin/warn_nosuspend.gif)

|
There is no difference between a struct and a class in C++, except that all members and inheritance defaults to private for a class, and public for a struct. Go ahead and define all the member functions you want in a struct, not that you generally have a reason to.
| QUOTE (C++ FAQ Lite) | The members and base classes of a struct are public by default, while in class, they default to private. Note: you should make your base classes explicitly public, private, or protected, rather than relying on the defaults.
struct and class are otherwise functionally equivalent.
OK, enough of that squeaky clean techno talk. Emotionally, most developers make a strong distinction between a class and a struct. A struct simply feels like an open pile of bits with very little in the way of encapsulation or functionality. A class feels like a living and responsible member of society with intelligent services, a strong encapsulation barrier, and a well defined interface. Since that's the connotation most people already have, you should probably use the struct keyword if you have a class that has very few methods and has public data (such things do exist in well designed systems!), but otherwise you should probably use the class keyword. |
--------------------
|
|
|
Xgoff |
|

<):|
![Super Happy Heart Badge [*]](https://archive.mfgg.net/html/badges/shappyheart.gif) ![Sprite Comp Winner Badge (1) [*]](https://archive.mfgg.net/html/badges/scg1.gif) ![Drawing Comp Winner Badge (1) [*]](https://archive.mfgg.net/html/badges/dcg1.gif) ![Drawing Comp Runner Up Badge (1) [*]](https://archive.mfgg.net/html/badges/dcr1.gif) ![MFGG Awards 2006 Winner [*]](https://archive.mfgg.net/html/badges/award06.gif)
![MFGG Awards 2007 Winner [*]](https://archive.mfgg.net/html/badges/award07.gif) ![Forum Event Badge [*]](https://archive.mfgg.net/html/badges/event.gif)

Group: Members
Posts: 52341
Member No.: 24
Joined: 13-October 03
Status: (0d)
![[--]](style_images/mfgg2_skin/warn_nosuspend.gif)

|
| QUOTE (Giygas @ Sep 25 2009, 10:52 AM) | | As annoying as it is to have to define each number in an array, |
you don't always have to do this
the card sequences in particular can be generated through a loop, all you really have to do is tell C++ how large the array needs to be (this depends on if you're using a single array for every card, four separate arrays, or whatever
--------------------
 DISCLAIMER: by sending me (xgoff) a private message, you agree to the directives and their terms specified henceforth: DIRECTIVE 1 (APPLE): i may or may not reply promptly or at all; and there are no guarantees to the usefulness of the reply. i may not acknowledge whether i have even received your private message DIRECTIVE 2 (CHILE CON CARNE): as per my view, "private" applies only to the initial transaction, and the material of your message may or may not be made public at my discretion; as this will more than likely be a post in the CCC or IRC, you may not be able to view it DIRECTIVE 3 (FEATHER DUSTER): you must address me (xgoff) as "Sir Master Xgofficus his Highest and Most Awesome the Third"; failure to comply with this term may invoke one or both of the above directives, and i will leave a burning bag of **** on your doorstep DIRECTIVE 4 (BOOTSTRAP): if you have read this disclaimer, please private message me promptly, in compliance with the above terms, so i can ensure you are capable of following directions you idiot this concludes the test of the emergency disclaimer system, your scheduled programming will now continue. satisfaction guaranteed, and 100% cash back available under certain circumstances; restrictions may or may not apply within your place of residence NOTICE: these directives and their terms may change at any time, without notice; as a private message transaction to myself assumes an understanding and full compliance of the above, you should ensure you are fully aware of the above terms at any point before sending a private message; any message received is assumed to have been sent in compliance with the above| QUOTE | (5:25:58 PM) Mikau: xgoff (5:26:00 PM) Mikau: guess what (5:26:04 PM) Xgoff: chicken butt (5:26:09 PM) Mikau: **** you |
|
|
|
Lightning |
|

Ignorance isn't stupidity but choosing to remain ignorant is
![Super Happy Heart Badge [*]](https://archive.mfgg.net/html/badges/shappyheart.gif) ![MFGG Awards 2008 Winner [*]](https://archive.mfgg.net/html/badges/award08.gif)

Group: IRC Operators
Posts: 6381
Member No.: 583
Joined: 31-August 04
Status: (0d)
![[--]](style_images/mfgg2_skin/warn_nosuspend.gif)

|
| QUOTE (Giygas @ Sep 25 2009, 01:06 PM) | Oh? So using a loop, I could do,
card[4][52];
Without having to name each variable? |
int deck[52];
should suffice.
then fill it up with unique values and then shuffle it.
that's how to avoid duplicates
thinking about how to "shuffle" is an exercise that should get you thinking a little like a programmer
This post has been edited by Lightning on Sep 25 2009, 12:20 PM
--------------------
click here to change my avatar. / gosh why are you even here lightninghacker, n.an individual who enjoys learning computer system details and how to capitalize on his or her capabilities...not a criminal. (from webster's new world hacker dictionary) |  Fedora 10 Final! Download today! | quality web comics (stories):- girl genius: adventure! romance! mad science!
- punch an' pie: try a slice of life, then swallow.
- dresden codak: most interesting comic ever
quality web comics (one-shots):- a softer world: truth and beauty bombs
- smbc: saturday morning breakfast cereal
- buttersafe: pictures and probably some words
|
"Religion is comparable to a childhood neurosis." - Sigmund Freud “It is not by delusion, however exalted, that mankind can prosper, but only by unswerving courage in the pursuit of truth.” - Bertrand Russell “To kill an error is as good a service as, and sometimes better than, the establishing of a new truth or fact.” - Charles Darwin
|
|
|
Giygas |
|

Standard Member
![Happy Heart Badge [*]](https://archive.mfgg.net/html/badges/happyheart.gif)

Group: Members
Posts: 910
Member No.: 4767
Joined: 24-November 07
Status: (0d)
![[--]](style_images/mfgg2_skin/warn_nosuspend.gif)

|
| QUOTE (Lightning @ Sep 25 2009, 12:55 PM) | no pointers yet.
int a = 5; int b = 8;
swap their values so that a ends up with 8 and b ends up with 5. that's a prerequisite for "shuffling" |
Hmm... Looks like i'm going to be doing some trial and error But first,  This will be the base part for when I get the shuffle working. Whee~
|
|
|
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:
Track this topic
Receive email notification when a reply has been made to this topic and you are not active on the board.
Subscribe to this forum
Receive email notification when a new topic is posted in this forum and you are not active on the board.
Download / Print this Topic
Download this topic in different formats or view a printer friendly version.
[ Script Execution time: 0.1263 ] [ 13 queries used ] [ GZIP Enabled ] [ Server Load: 1.27 ]
| |