Thread: Structures? *brain melts*

  1. #106
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    http://newdata.box.sk/bx/c/
    Read everything at this site, and do all the activities. Then figure out what you want to achieve with a program, and try to do it.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  2. #107
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    Then don't work with windows yet - theres plenty more to C++ then pointers and structures. Once you get bored, try looking into the Standard Template Library.
    Do not make direct eye contact with me.

  3. #108
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    Originally posted by bennyandthejets
    http://newdata.box.sk/bx/c/
    Read everything at this site, and do all the activities. Then figure out what you want to achieve with a program, and try to do it.
    SAMS BOOK! VOID MAIN! KILL THE LINK NOW BEFORE IT SPAWNS!
    Do not make direct eye contact with me.

  4. #109
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    I don't remember it using void main. Although, it has been a couple years now.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  5. #110
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    well I don't know what kind of program to write. I only know a little bit, enough for a console program. If it comes down to windows apps, I'm screwed
    There's tons you can do in console mode...you definitely want to get used to as many topics as you can in console mode before you move to windows programming
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  6. #111
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Then don't work with windows yet

    Best piece of advice yet. As for the STL I still have yet to really dive into it. I've used it but not extensively. There's always something else to explore in programming. That's why we love it so much.

    You'll never master it all.

  7. #112
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    Well the part i looked at had it.....anyway its still a 21 days book - not many people here trust it, they arent very good on average.

    EDIT: and just look at the first 3 lines of their hello world:

    Code:
    #include <iostream.h>
    
    int main(){
    Do not make direct eye contact with me.

  8. #113
    Registered User MrDoomMaster's Avatar
    Join Date
    Oct 2003
    Posts
    53
    Thank you so much everyone for helping out. I have learned a LOT more than I expected tonight.

    But, it is to everyone's disappointment that this post will come to its demise. It grew so fast! lol... Oh well, it's been fun! I'll work on programming stuff! Thanks for everything!
    --MrDoomMaster
    The kind of DooM that makes the MooD

  9. #114
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Ok, I just checked it. They use int main() religiously. And it's a very good book, it's how I learnt most of my c++.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  10. #115
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Actually its rather refreshing this thread is ending - cuz it's making my head spin.

    But I'm sure at least 50 or so more people will bump it.

    It's been real. And to my fellow partners in crime...it's been fun guys.

  11. #116
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    Originally posted by MrDoomMaster
    Thank you so much everyone for helping out. I have learned a LOT more than I expected tonight.

    But, it is to everyone's disappointment that this post will come to its demise. It grew so fast! lol... Oh well, it's been fun! I'll work on programming stuff! Thanks for everything!
    Yay! OK DON'T POST NOW JAWIB.

    j/k .
    Do not make direct eye contact with me.

  12. #117
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Yay! OK DON'T POST NOW JAWIB.
    *Tries to keep mouth shut*

    Darn.
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  13. #118
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    But I'm sure at least 50 or so more people will bump it.
    I'll be the first.

    Well, I got back in a little late, and though I tried to read over everything, some of that was a bit hard to follow. Anyways, this should be helpful on the difference between pointers and references.

    Both do essentially the same thing. They point to a address in memory. A reference is a much 'safer' version of a pointer, however.

    A reference:
    - Must point to an already existing object
    - Cannot be null
    - Cannot be changed (that is, it cannot point to a different object later)
    - As it creates no memory, never requires the user to cleanup

    To create a reference, you use & after the type:
    int a; // Create a new int
    int& x = a; // Create a reference to a named x

    A pointer:
    - Can point to an existing object (using the addressof - & - operator if what you are assigning it to is not already a pointer), a newly allocated object (using 'new'), or an array of newly created objects (using 'new[]')
    - Can be null (0)
    - Can be changed
    - Depending on how it is used, may require cleanup (using 'delete' or 'delete[]'), or may not, but you better be sure not to use something that you've already destroyed

    Here are some pointer examples:
    int a;
    int* b = &a;
    int* c = b;
    int* d = new int;
    int* e = new int[10];
    delete d;
    delete[] e;

    Another difference in behavior comes with polymorphism. If you unsuccessfully dynamic_cast a pointer, you will have a null pointer returned. If you unsuccessfully dynamic_cast a reference, an exception will be thrown.

    Also, some notes on const.

    const type& - means that the object pointed to by the reference cannot be changed through the reference.

    const type* - means the data pointed to by the pointer cannot be changed through the pointer, but you can change what data is pointed to

    type* const - means that you cannot reassign the pointer, but you can change the data it points to

    and...

    const type* const - means the pointer cannot be reassigned, nor can you change the data it points to

    Note that type& const is redundant

    const type* = type const*
    const type& = type const&
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  14. #119
    Registered User MrDoomMaster's Avatar
    Join Date
    Oct 2003
    Posts
    53
    I asked earlier about decent compilers, anyone have any recommendations? I'm using Bloodshed Dev-C++ compiler, and the interface is amazing. I really like it. Any comments?
    --MrDoomMaster
    The kind of DooM that makes the MooD

  15. #120
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    Originally posted by MrDoomMaster
    I asked earlier about decent compilers, anyone have any recommendations? I'm using Bloodshed Dev-C++ compiler, and the interface is amazing. I really like it. Any comments?
    I need a post in this thread.

    If you like it; use it. If you can get your hands on a copy of MSVC though... it's very nice. Assuming you're coding on a windows machine.

    GCC is probably the most standards compliant compiler that you're likely to find, but doesn't have an IDE. It's free, though. Unlike MSVC (assuming legal means).
    Away.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 07-11-2008, 07:39 AM
  2. Structures, passing array of structures to function
    By saahmed in forum C Programming
    Replies: 10
    Last Post: 04-05-2006, 11:06 PM
  3. Input output with structures
    By barim in forum C Programming
    Replies: 10
    Last Post: 04-27-2004, 08:00 PM
  4. pointers to arrays of structures
    By terryrmcgowan in forum C Programming
    Replies: 1
    Last Post: 06-25-2003, 09:04 AM
  5. Methods for Sorting Structures by Element...
    By Sebastiani in forum C Programming
    Replies: 9
    Last Post: 09-14-2001, 12:59 PM