Thread: About vectors.

  1. #16
    Registered User
    Join Date
    Aug 2008
    Posts
    30
    matsp you NEVER fail me! Thank you! That was really helpful!

  2. #17
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Although after a "beginners" book, there are lots of advanced books out there.
    Then there are design books and such. You can never learn enough.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #18
    Registered User
    Join Date
    Aug 2008
    Posts
    30
    O0O
    But you see actually the reason I'm trying to learn so much is because theres a small group(really small group) of people in my class who know ALOT more than what we are currently learning and I want to be able to do stuff like they do(adding pictures, etc, etc) but I'm not sure what exactly to learn. Currently all I know are...

    -Cin(.ignore,.get,etc),

    -Cout,

    -Loops,

    -If, Else if,

    -Arrays(2D and onward),

    mostly the really basic stuff

    -A little on File I/O(indata, outdata, etc),

    -Structs,

    -Classes(though I'm not really good at it) no inheritance though,

    Pointers(but I NEVER use them except during practicals ON vectors because I don't see why I would need them)

    AND THEN I am currently trying to learn...

    -Vectors(because they are cool)

    -Iterators(because they came along with vectors and just like pointers, I don't really see the need for them, am I like pointer-blind? O_O)

    -Algorithm

    -Maps(but I only know how to declare them)

    -How to make simple games!(I'm trying to do English Chess xD, good idea?)

    Yeah, I think that's just about it.
    Last edited by KgNe; 09-03-2008 at 08:12 AM. Reason: No reason really. No big difference -_-

  4. #19
    The larch
    Join Date
    May 2006
    Posts
    3,573
    How to make simple games!(I'm trying to do English Chess xD, good idea?)
    Chess AI is a science of its own, but a simple interface for two human player games (that can detect correctness of moves, draw and win conditions, do game timing, perhaps replays after the game is over, taking moves back etc) should be quite doable at some point.

    Somewhere quite early you should be able to write a Guess a number game (could be both ways, human guessing a computer-picked number and the other way round).

    Then perhaps a Hangman game.

    Tic-Tac-Toe is popular too, but complete beginners tend to implement it in awful ways (there are examples of the game written without any arrays or loops at all ), so that might be an intermediate level challenge.

    Of simple graphical games, Pong, Tetris, Breakout and similar are popular choices.

    Pointers(but I NEVER use them except during practicals ON vectors because I don't see why I would need them)
    I don't quite understand this sentence, but storing pointers in a vector, or storing pointers to vector items are not very good ideas.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  5. #20
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Storing pointers in a vector is usually a good solution, though, when you don't want data copied needlessly.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #21
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Quote Originally Posted by Elysia View Post
    Storing pointers in a vector is usually a good solution, though, when you don't want data copied needlessly.
    Then use a shared pointer implementation like the one boost has. Raw pointers in a vector is never a good idea because you have to manage memory explicitly.

  7. #22
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Or use a special-purpose container, such as boost::ptr_vector.

    When you store pointer to dynamically allocated objects in a regular vector, not only is it your responsibility to free the memory yourself, but also certain functions become unusable (such as std::remove).

    Basically you'd be potentially required to write much more explicit memory handling code than just releasing the memory at the end.

    In addition, it won't be exception safe.
    Last edited by anon; 09-03-2008 at 11:58 AM.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  8. #23
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Naturally. I never leave home without smart pointers these days!
    Of course, a smart pointer is technically still a pointer, so the argument still holds
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #24
    Registered User
    Join Date
    Aug 2008
    Posts
    30
    Quote Originally Posted by anon View Post
    Chess AI is a science of its own, but a simple interface for two human player games (that can detect correctness of moves, draw and win conditions, do game timing, perhaps replays after the game is over, taking moves back etc) should be quite doable at some point.
    Yep, my teacher showed us this video where this supercomputer beat this professional at chess.

    Somewhere quite early you should be able to write a Guess a number game (could be both ways, human guessing a computer-picked number and the other way round).
    Yep, had to do it in one of my practicals, though still quite unclear about the effects of srand(time(NULL)).

    Then perhaps a Hangman game.

    Tic-Tac-Toe is popular too, but complete beginners tend to implement it in awful ways (there are examples of the game written without any arrays or loops at all ), so that might be an intermediate level challenge.
    Cool! I have a book which uses these two games as an example.

    Of simple graphical games, Pong, Tetris, Breakout and similar are popular choices.

    I don't quite understand this sentence, but storing pointers in a vector, or storing pointers to vector items are not very good ideas.
    Thanks for the great ideas, same for everyone else. xD But I guess it'll be some time before I start using pointers instinctively like while loops.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Vectors
    By naseerhaider in forum C++ Programming
    Replies: 11
    Last Post: 05-09-2008, 08:21 AM
  2. How can i made vectors measuring program in DevC++
    By flame82 in forum C Programming
    Replies: 1
    Last Post: 05-07-2008, 02:05 PM
  3. How properly get data out of vectors of templates?
    By 6tr6tr in forum C++ Programming
    Replies: 4
    Last Post: 04-15-2008, 10:35 AM
  4. How to use Vector's in C++ !?!
    By IndioDoido in forum C++ Programming
    Replies: 3
    Last Post: 10-14-2007, 11:13 AM
  5. Points, vectors, matrices
    By subnet_rx in forum Game Programming
    Replies: 17
    Last Post: 01-11-2002, 02:29 PM