Page 1 of 6 123 ... LastLast
Showing results 1 to 20 of 106

Thread: C++ Questions

  1. #1

    Default C++ Questions

    C++ Questions
    1. Why are pointers useful?(*,&)
    2.What does void do? {i.e. int sumSequence(void)}
    3. Why do most programs have "int main(int nNumberofArgs, char*pszArgs[])
    4.Why does it sometimes say ( ;; )? {i.e. for( ;; )} Or is this just a specific example?
    5. What's the difference if the increment operator comes before or after the variable? {i.e. (i++) vs. (++i)}
    6. Is "Of" a keyword? And if it is what is it used for?
    7. Why is it that they declare what something is twice? {i.e. float floatArray}
    8. For pointers why is there one for expression and one for declaration? What's the difference?
    9. Why would you need to pass a pointer value?
    10. How do offsets work in C++? {i.e.:
    Offset | Result | Is the address of
    +0 | | | 0x110| | | charArray[0]
    11. Does endl mean end line?
    12. What is setting a breakpoint and why would you need to do it?
    13. How can you tell if you need to use brackets or parantheses etc...?
    14. What does the scope resolution operator do?
    15. Why can't you just use cout instead of return value?
    16. Why do the end of most programs have return 0; ?
    17. What is "->"?
    18. What are 2 "::" for? {i.e. student::Student()} I read in a chapter about it stating its not a member of a class, but then it goes and says "::Student" in another part.

    Thank you!
    Thank you for all help that will be offered. These are all questions that I have read about and then re-read and still have not been able to figure out. Please don't flame me for my lack of knowledge. I am trying to learn, but some help would be greatly appreciated!
    Note: In number 10. the part that has 3 "|" in it, it was because it wouldn't space. It is merely for spacing purposes only and the only important part are the actual numbers. Thank again!
    ~~~Crazy_AMHP_erage~~~
    Last edited by Crazy_AMHP_erage : 01-24-2005 at 05:51 PM
    Don't mess with my wiggle.

    ZyZ (11:05:48 PM): I'm
    ZyZ (11:05:49 PM): ****ing
    ZyZ (11:05:49 PM): bi

  2. #2
    Senior Member
    Gold Member

    High Priest
    YonderKnight's Avatar
    Join Date
    Sep 2004
    Location
    USA, California
    Posts
    1,442

    Default

    12. What is setting a breakpoint and why would you need to do it?
    Setting a breakpoing on a specific line of code is basically making the program stop whenever it runs that line of code. You can use it in debugging, like if something isn't working, you can set a bp on it to check if it is even being ran o not.

    15. Why can't you just use cout instead of return value?
    Cout is used for pintin text in a command prompt.
    Whenever you call a function, letssay FindWindow(void, "Brood War"), returns a value, in this case, the window handle of Brood War. If you want to stoe that value, you would have to do
    BroodWarWnd = FindWindow(void, "Brood Wa")
    The function FindWindow uses Retun Value to return the number of windowso open. Also, a lot of API's and stuff return values depending on if they succeeded in doin what they whee supposed to do or not.

    16. Why do the end of most programs have return 0; ?
    If you need to run a function that does not eally need to retun anything, people eithe use this o "Return Void" (I think).

    I don't really know that much C++, so that's about all I can help you with.
    Somebody correct me if any of those are wrong

  3. #3

    Default

    Quote Originally Posted by YonderKnight
    Setting a breakpoing on a specific line of code is basically making the program stop whenever it runs that line of code. You can use it in debugging, like if something isn't working, you can set a bp on it to check if it is even being ran o not.



    Cout is used for pintin text in a command prompt.
    Whenever you call a function, letssay FindWindow(void, "Brood War"), returns a value, in this case, the window handle of Brood War. If you want to stoe that value, you would have to do
    BroodWarWnd = FindWindow(void, "Brood Wa")
    The function FindWindow uses Retun Value to return the number of windowso open. Also, a lot of API's and stuff return values depending on if they succeeded in doin what they whee supposed to do or not.



    If you need to run a function that does not eally need to retun anything, people eithe use this o "Return Void" (I think).

    I don't really know that much C++, so that's about all I can help you with.
    Somebody correct me if any of those are wrong
    Alrighty thanks Yonderknight!
    Questions Already Answered
    12.,15.,16.
    Don't mess with my wiggle.

    ZyZ (11:05:48 PM): I'm
    ZyZ (11:05:49 PM): ****ing
    ZyZ (11:05:49 PM): bi

  4. #4
    Retired Staff Member

    High Priest

    Join Date
    Mar 2004
    Location
    Marietta, Ga
    Posts
    1,711

    Default

    1. Why are pointers useful?(*,&)
    Because stack size is limited when passing parameters to a function, such as an array.

    2.What does void do? {i.e. int sumSequence(void)}
    Nothing. It's best to simply leave it out.

    3. Why do most programs have "int main(int nNumberofArgs, char*pszArgs[])
    Most don't.

    [quote]4.Why does it sometimes say ( ;; )? {i.e. for( ;; )} Or is this just a specific example?[quote]
    It's a specific example of an infinite loop.

    5. What's the difference if the increment operator comes before or after the variable? {i.e. (i++) vs. (++i)}
    Order of operations. For example, if you call a function (ex. somefunc(i++);) with the former, it will get i instead of i+1. The latter will cause the function to get i+1.

    6. Is "Of" a keyword? And if it is what is it used for?
    No.

    9. Why would you need to pass a pointer value?
    Once again, stack size is limited.

    11. Does endl mean end line?
    Stay away from the bullshit c++ i/o classes.

    12. What is setting a breakpoint and why would you need to do it?
    If a breakpoint is set on a certain line of code, the debugger will stop the program at that line of code and allow you to debug it.

    13. How can you tell if you need to use brackets or parantheses etc...?
    Shouldn't you know that by now?

    15. Why can't you just use cout instead of return value?
    Because cout is for printing to the console only.

    16. Why do the end of most programs have return 0; ?
    The last return statement in a program signifies the exit code, and an exit code of 0 in windows is the de-facto standard of a normal exit.

    17. What is "->"?
    This is a way of dereferencing members of structures/classes when given their pointer. For instance:
    Code:
    POINT *p = {NULL};
    *p.x = 1;
    p->x = 1;
    The last two lines have identical functionality.

  5. #5
    Back from the dead Senior Member
    Developer

    Enlightened
    Fish Beans's Avatar
    Join Date
    Jul 2004
    Location
    That's classified
    Posts
    3,098

    Default

    Quote Originally Posted by Crazy_AMHP_erage
    C++ Questions
    1. Why are pointers useful?(*,&)
    Usually it's a speed issue (though not always). Passing a struture with 100 elements will take considerably longer than just passing the location of that structure.
    2.What does void do? {i.e. int sumSequence(void)}
    void means it has no data type. This is usually used in type casting (which you probably aren't too worried about right now).
    3. Why do most programs have "int main(int nNumberofArgs, char*pszArgs[])
    I've actually never written a program that passed arguments to main. Just look at how that data is used to see why it was in there
    4.Why does it sometimes say ( ;; )? {i.e. for( ;; )} Or is this just a specific example?
    for( ;; ) is a for loop that will execute until a break, just like while (1). For loops are the only thing I can think of that can use ( ;; ) legally.
    5. What's the difference if the increment operator comes before or after the variable? {i.e. (i++) vs. (++i)}
    Well, if you are just incrementing, it has no impact, but if you wanted to increment while performing another operation, such as cout or printf, it does matter. If you put it before the variable, it whatever is currently using it will see the incremented value. Afterwards and it will get the value before increment.
    6. Is "Of" a keyword? And if it is what is it used for?
    No, of is not a keyword that I'm aware of.
    7. Why is it that they declare what something is twice? {i.e. float floatArray}
    Your example actually isn't declaring it twice, floatArray is the name of the variable. You could do float intdwordbytefloatlongunsignednumber if you wanted to.
    8. For pointers why is there one for expression and one for declaration? What's the difference?
    Not quite sure what you mean.
    9. Why would you need to pass a pointer value?
    If you wanted to directly modify that variable, you'd have to pass it by reference (a pointer). Also, it's more efficient when passing large variables (such as strings and structures).
    10. How do offsets work in C++? {i.e.:
    Offset | Result | Is the address of
    +0 | | | 0x110| | | charArray[0]
    You'd do it like this. type *pPointerName = (type*) (BaseAddress + Offset Address);
    11. Does endl mean end line?
    That's part of the namespace std, which I don't use. I'm pretty sure it's just another way to write "\n".
    12. What is setting a breakpoint and why would you need to do it?
    When debugging your program, it's often useful to have it stop in a particular spot so you can step through and watch what's happening.
    13. How can you tell if you need to use brackets or parantheses etc...?
    Never really thought about that, I guess it's just one of those things you pick up as you go. There are a lot of things that always use parentheses, and a lot of things that always use brackets.
    14. What does the scope resolution operator do?
    In a nutshell, it allows you to use "hidden" variables/objects. Something may become hidden for a number of reasons, such as a local variable/object existing with the same name.
    15. Why can't you just use cout instead of return value?
    They are two completely different things. cout is for output, return is to pass a value back to where the function was called.
    16. Why do the end of most programs have return 0; ?
    Because main returns an int, 0 usually means no errors, so it's often used.
    17. What is "->"?
    It means "points to".
    18. What are 2 "::" for? {i.e. student::Student()} I read in a chapter about it stating its not a member of a class, but then it goes and says "::Student" in another part.
    That's the scope resolution operator, already addressed.
    This space still for rent.

  6. #6

    Default

    Ok great thanks a lot you guys. I am going to study it, thank you so much Fish Beans, Nickolay, and Yonderknight. And thanks you guys for answering it from two different perspectives. It should really help me out. Thank you very much. You guys dont realize how much this helps me. Now hopefully I can make sense of the code of which I could not. Thank you a million times over. This means a lot. THANK YOU!!! :D :top: Oh and please don't delete these posts. I am using them to study off of them. Thanks again!
    Last edited by Crazy_AMHP_erage : 01-24-2005 at 08:49 PM
    Don't mess with my wiggle.

    ZyZ (11:05:48 PM): I'm
    ZyZ (11:05:49 PM): ****ing
    ZyZ (11:05:49 PM): bi

  7. #7
    ?▪▫▪ PaRaNoiA EvOlUtIoN ▪▫▪? Senior Member

    Messiah
    Dr. Silence's Avatar
    Join Date
    Jun 2004
    Location
    Dumpster (bearcave)
    Posts
    8,963

    Default

    Quote Originally Posted by Crazy_AMHP_erage
    Now hopefully I can make sense of the code of which I could not.
    Post the code...
    Silence, your signature is to fuking big, next time you do this your signature will be disabled.
    <3 LCS

    [/QUOTE]

    d2V.

  8. #8

    Default

    Quote Originally Posted by Silence
    Post the code...
    No for two reasons:
    1. I want to figure it out on my own now that I have gotten the things that were stumping me answered.
    2. They're in a book. Besides now I should be able to understand it fairly easy. The code I have reviewed so far I have ;) I finally got to the point where I am reading more instead of just reviewing. :D

    But thank you for the offer of helping me Not to come down so hard, but I need to learn these things my self other whys I will be completely useless at programming. Well maybe not completely but my point being I just need to learn the rest on my own...unless I really get stuck and then I will keep that offer in mind silence. And keep the nice people at BWHacks in mind too. ;) :D
    Don't mess with my wiggle.

    ZyZ (11:05:48 PM): I'm
    ZyZ (11:05:49 PM): ****ing
    ZyZ (11:05:49 PM): bi

  9. #9
    ?▪▫▪ PaRaNoiA EvOlUtIoN ▪▫▪? Senior Member

    Messiah
    Dr. Silence's Avatar
    Join Date
    Jun 2004
    Location
    Dumpster (bearcave)
    Posts
    8,963

    Default

    Quote Originally Posted by Crazy_AMHP_erage
    No for two reasons:
    1. I want to figure it out on my own now that I have gotten the things that were stumping me answered.
    2. They're in a book. Besides now I should be able to understand it fairly easy. The code I have reviewed so far I have ;) I finally got to the point where I am reading more instead of just reviewing. :D

    But thank you for the offer of helping me Not to come down so hard, but I need to learn these things my self other whys I will be completely useless at programming. Well maybe not completely but my point being I just need to learn the rest on my own...unless I really get stuck and then I will keep that offer in mind silence. And keep the nice people at BWHacks in mind too. ;) :D
    Ive been learning c++ for one year, but i keep stopping and starting.. at this point you most likely know much more then me but heres on place... its basically smarter then the whole staff here mixed together (no offence) www.neworder.box.sk is really good to ask questions and they know everything, its how i started... its a security portal site so its also about exploits and server corruption and all neat little things thats so much fun to try out, also www.hackthissite.org has a few tuts on every section of c++ ever possible to cover.
    Silence, your signature is to fuking big, next time you do this your signature will be disabled.
    <3 LCS

    [/QUOTE]

    d2V.

  10. #10

    Default

    Quote Originally Posted by Silence
    Ive been learning c++ for one year, but i keep stopping and starting.. at this point you most likely know much more then me but heres on place... its basically smarter then the whole staff here mixed together (no offence) www.neworder.box.sk is really good to ask questions and they know everything, its how i started... its a security portal site so its also about exploits and server corruption and all neat little things thats so much fun to try out, also www.hackthissite.org has a few tuts on every section of c++ ever possible to cover.
    Alrighty cool thanks for the reference. I am gonna check it later when I get home and back on my laptop ;)
    Don't mess with my wiggle.

    ZyZ (11:05:48 PM): I'm
    ZyZ (11:05:49 PM): ****ing
    ZyZ (11:05:49 PM): bi

  11. #11
    Arbiter Senior Member
    Retired Staff Member

    Blessed
    TheTempest's Avatar
    Join Date
    Apr 2004
    Posts
    2,086

    Default

    -Stuck-

    Great thread guys.

    My signature is back!! Hell YES!

    Click the link, I DEMAND YOU! :-D
    http://www.bwhacks.com/forums/showthread.php?t=24873

  12. #12

    Default

    Hey mods feel free, since this is stuck, to delete any of my stupid posts "flaming" him.
    Don't mess with my wiggle.

    ZyZ (11:05:48 PM): I'm
    ZyZ (11:05:49 PM): ****ing
    ZyZ (11:05:49 PM): bi

  13. #13
    ?▪▫▪ PaRaNoiA EvOlUtIoN ▪▫▪? Senior Member

    Messiah
    Dr. Silence's Avatar
    Join Date
    Jun 2004
    Location
    Dumpster (bearcave)
    Posts
    8,963

    Default

    http://www.planetsourcecode.com

    excellent for lots of codes
    Silence, your signature is to fuking big, next time you do this your signature will be disabled.
    <3 LCS

    [/QUOTE]

    d2V.

  14. #14

    Default

    Quote Originally Posted by Silence
    http://www.planetsourcecode.com

    excellent for lots of codes
    Yeah I've gone there before, but thanks for the headsup. There are a lot of sites thanks to :google: Thanks again.
    Don't mess with my wiggle.

    ZyZ (11:05:48 PM): I'm
    ZyZ (11:05:49 PM): ****ing
    ZyZ (11:05:49 PM): bi

  15. #15
    Retired Staff Member

    Zealot
    Palomino's Avatar
    Join Date
    Jul 2004
    Location
    NSW, Australia
    Posts
    754

    Default

    http://www.codeproject.com/ is another great site with tutorials and code for most programming languages. I am a proud member there.

  16. #16

    Default

    asm
    auto
    bool
    break
    case
    catch
    char
    class
    const
    const_cast
    continue
    default
    delete
    do
    double
    dynamic_cast
    else
    enum
    explicit
    export
    extern
    false
    float
    for
    friend
    goto
    if
    inline
    int
    long
    mutable
    namespace
    new
    operator
    private
    protected
    public
    register
    reinterpret_cast
    return
    short
    signed
    sizeof
    static
    static_cast
    struct
    switch
    template
    this
    throw
    true
    try
    typedef
    typeid
    typename
    union
    unsigned
    using
    virtual
    void
    volatile
    wchar_t
    while

    Is that a bad source or am I missing something? I know there are more keywords for that...Not even cin or cout in there...So, can anyone tell me if it's just maybe a bad source or if I am seriously missing something.
    Don't mess with my wiggle.

    ZyZ (11:05:48 PM): I'm
    ZyZ (11:05:49 PM): ****ing
    ZyZ (11:05:49 PM): bi

  17. #17
    Senior Member
    Retired Staff Member

    Saint
    llafnwod's Avatar
    Join Date
    Jul 2004
    Posts
    6,026

    Default

    Quote Originally Posted by Uniquely_Defined
    Is that a bad source or am I missing something? I know there are more keywords for that...Not even cin or cout in there...So, can anyone tell me if it's just maybe a bad source or if I am seriously missing something.
    Uh, cin and cout are string operaters in the std class included in iostream. It's a function, not a keyword. The >> and << are just overloaded operators.
    NEWS YOU CAN USE. IF YOU CHOOSE NOT TO USE THIS NEWS YOU WILL BE KILLED.

  18. #18

    Default

    Quote Originally Posted by llafnwod
    Uh, cin and cout are string operaters in the std class included in iostream. It's a function, not a keyword. The >> and << are just overloaded operators.
    Ahh I see. Thanks llafnwood.
    EDIT: llafnwod???
    Don't mess with my wiggle.

    ZyZ (11:05:48 PM): I'm
    ZyZ (11:05:49 PM): ****ing
    ZyZ (11:05:49 PM): bi

  19. #19

    Deviant
    A.H's Avatar
    Join Date
    Mar 2005
    Location
    Austrailia
    Posts
    158

    Default

    Seems like most, if not all of the keywords to me.
    Cowards die many times before their deaths;
    The valiant never taste of death but once.

  20. #20

    Default

    Alrighty thanks both of you. Mostly laffnwod, you just confirmed me A.H
    Don't mess with my wiggle.

    ZyZ (11:05:48 PM): I'm
    ZyZ (11:05:49 PM): ****ing
    ZyZ (11:05:49 PM): bi

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Questions about all these hacks.
    By d0pe in forum Starcraft/Brood War
    Replies: 12
    Last Post: 04-02-2005, 09:34 PM
  2. Google Adsense Questions
    By Marine6592 in forum General Chat
    Replies: 4
    Last Post: 04-01-2005, 06:25 AM
  3. Questions about Damnation and inhale
    By Teddy in forum Starcraft/Brood War
    Replies: 13
    Last Post: 12-29-2004, 12:37 PM
  4. Blackllama Questions
    By llafnwod in forum Flame Board
    Replies: 33
    Last Post: 12-05-2004, 03:37 PM
  5. Questions on hacking
    By x2570 in forum Starcraft/Brood War
    Replies: 4
    Last Post: 10-07-2004, 03:47 PM

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •