Thread: Structures? *brain melts*

  1. #76
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    That means that there are no arguments to the function, so the parameter list is void.
    Do not make direct eye contact with me.

  2. #77
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Hey MrDoomMaster remind all of us here never to write a book about C/C++. We are all over the page here. We've gone from like chapter 22 to chapter 1 to chapter 5.

    void
    • Means that the function does not return any value
    • Can also mean that no parameters are passed to a function
    • Basically means no data type


    And I'm sure my pals will add to the list.

  3. #78
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    Thats why 5+ people never gang up to write a C++ book, bubba .
    Do not make direct eye contact with me.

  4. #79
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    This thread is already number 5 for number of replies on the C++ board (as far as I can tell)
    "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

  5. #80
    Registered User MrDoomMaster's Avatar
    Join Date
    Oct 2003
    Posts
    53
    Originally posted by JaWiB
    Maybe some code will clear things up:
    Code:
    #include <iostream>
    using namespace std;
    int Global=0;
    int Func1()
    {
    int a=1;
    int b=2;
    return a+b;
    
    }
    
    //a,b now gone
    int Func2()
    {
    return Global++; //can be changed and accessed since it is global 
    }
    
    int Func3(int val)
    {
    Global=val;
    return Global;
    }
    
    int Func4(int& val)
    {
    val=10;
    return val;
    }
    int main()
    {
    int MainVar=25;
    int MainVar2=20;
    cout<<Func1()<<endl;//outputs 3
    cout<<Func2()<<endl;//outputs 0, Global now 1
    cout<<Global<<endl;//outputs 1;
    cout<<Func3(MainVar)<<endl;//outputs 25, Global now 25
    cout<<Global<<endl;//outputs 25
    cout<<Func4(MainVar)<<endl;//outputs 10, MainVar now 10 
    cout<<MainVar<<endl;//outputs 10
    //note MainVar could not be changed without passing it as 
    //a reference, since its scope is within main()
    }

    in your code I saw "int Func4(int& val)"

    I thought you put the & in front of the variable to get the address of that variable? Why is it after the type?
    --MrDoomMaster
    The kind of DooM that makes the MooD

  6. #81
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    I came in at 44 - now its 80 .
    Do not make direct eye contact with me.

  7. #82
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Yeah way to go JaWib. We were actually getting somewhere till you posted code. Now on to another tangent.



    We should rename this thread for all the newbies - The complete guide on how to program in C/C++.

  8. #83
    Registered User MrDoomMaster's Avatar
    Join Date
    Oct 2003
    Posts
    53
    lol... See why I like this forum so much? people actually TALK!!... in my previous forum I was it, I would be lucky to get 3 replies in 4 years...
    --MrDoomMaster
    The kind of DooM that makes the MooD

  9. #84
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    in your code I saw "int Func4(int& val)"

    I thought you put the & in front of the variable to get the address of that variable? Why is it after the type?
    I could have also done:
    Code:
    int Func4(int &val) 
    //or
    int Func4(int & val)
    Clearer?
    "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

  10. #85
    Registered User MrDoomMaster's Avatar
    Join Date
    Oct 2003
    Posts
    53
    Originally posted by JaWiB
    I could have also done:
    Code:
    int Func4(int &val) 
    //or
    int Func4(int & val)
    Clearer?

    oh yes, I get it now. It's just the way you form it. Got it!

    But see, that's where pointers confuse me. If a variable already has the information... why do you have to use a pointer to point to that value that the variable already has? Why not use the variable to get the data, instead of a pointer?
    --MrDoomMaster
    The kind of DooM that makes the MooD

  11. #86
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Well what we like to see are people who are not afraid to learn, not afraid to make mistakes (as you've seen by my posts), and not afraid to listen.

    If you post with the right attitude...this is the end result - a huge thread where everyone wants to help. It is a great place to be here on the board.


    Now where were we with the programming?

  12. #87
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    The & can be put in any of these ways correctly:
    int &x
    int & x
    int& x
    int & x

    Get it ? (Thanks a lot Jawib )
    Do not make direct eye contact with me.

  13. #88
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Yeah way to go JaWib. We were actually getting somewhere till you posted code. Now on to another tangent.
    Thats what programmings all about Confusion!! Hurray!

    At some point though, DoomMaster, you're going to have to write some code for yourself....then you'll understand

    We should rename this thread for all the newbies - The complete guide on how to program in C/C++.
    Hm maybe this should go to the faq board
    "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

  14. #89
    Registered User MrDoomMaster's Avatar
    Join Date
    Oct 2003
    Posts
    53
    Originally posted by Bubba
    Well what we like to see are people who are not afraid to learn, not afraid to make mistakes (as you've seen by my posts), and not afraid to listen.

    If you post with the right attitude...this is the end result - a huge thread where everyone wants to help. It is a great place to be here on the board.


    Now where were we with the programming?

    I would hit the people that say a "bubba" is some fat scary gay dude in jail waiting for newcomers... absolute nonsense!

    Bubba actually tends to be an experienced programmer... not a fat guy in a jail cell!
    --MrDoomMaster
    The kind of DooM that makes the MooD

  15. #90
    Registered User MrDoomMaster's Avatar
    Join Date
    Oct 2003
    Posts
    53
    Originally posted by JaWiB
    Thats what programmings all about Confusion!! Hurray!

    At some point though, DoomMaster, you're going to have to write some code for yourself....then you'll understand



    Hm maybe this should go to the faq board
    LOL
    --MrDoomMaster
    The kind of DooM that makes the MooD

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