pointers again

This is a discussion on pointers again within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by lilhawk2892 i swear to god if one more person does the "like"thing,i only did it once or ...

  1. #16
    Registered User
    Join Date
    Apr 2006
    Posts
    2,027
    Quote Originally Posted by lilhawk2892
    i swear to god if one more person does the "like"thing,i only did it once or twice

    and how would i limit down my code then
    Loops and functions.

    For example, write a print stat function for whenever you need to print the stats.

    Or for a more OO aproach, make the stats a class, and have a print meathod.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  2. #17
    Registered User
    Join Date
    May 2006
    Posts
    903
    Or overload the << operator.
    Code:
    class myClass {
        public:
            std::ostream& operator << (std::ostream& os, myClass& mc) {
                os << a << ' ' << b << std::endl;
                return os;
            }
        private:
            int a, b;
    };
    Something along these lines. I haven't done this in a while.

  3. #18
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    Quote Originally Posted by citizen
    > and how would i limit down my code then
    You need to learn the 80/20 rule. One application is, "If your program does anything useful 80 lines of code accounts for 20% of what it does." You can not apply this literally, but as we've been saying you can not expect every application or game to work in <100 lines of code. In fact, most don't.
    eh? WTF are you talking about? the 80/20 rule states that 80% of the execution time will be spent in 20% of the code (although in reality it's often closer to 90/10).
    "I saw a sign that said 'Drink Canada Dry', so I started"
    -- Brendan Behan

    Free Compiler: Visual C++ 2005 Express
    If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?

  4. #19
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,667
    The 80/20 rule has many applications, but I bended the principle to say what I wanted to say. I explained what I was talking about. And 90/10 is improper.

    edit: I dp not intentionally give wrong advice. I'm wrong a lot. However, I simply have to explain things in a different way because thinking is hard.
    Last edited by whiteflags; 07-05-2006 at 10:52 PM.

  5. #20
    Registered User
    Join Date
    Sep 2005
    Posts
    196
    >citizen:
    errr its ok i didnt understand it anyways...

    >mario.f:
    thank you i didnt even think about that even though ive been using functions for everything else...ill make that

    oh and im already up to 124 lines in about 1 minute of the game running lol.i expect easily a couple thousand XD

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using pointers to pointers
    By steve1_rm in forum C Programming
    Replies: 18
    Last Post: 05-29-2008, 05:59 AM
  2. function pointers
    By benhaldor in forum C Programming
    Replies: 4
    Last Post: 08-19-2007, 10:56 AM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM
  4. Staticly Bound Member Function Pointers
    By Polymorphic OOP in forum C++ Programming
    Replies: 29
    Last Post: 11-28-2002, 12:18 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21