Thread: concatenation

  1. #16
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Top reasons to use C++ streams with << and >>
    • Faster (with a good compiler/library). The program doesn't have to parse a format string. The types to be printed are known compile-time, which gains speed.
    • OOP. If I create my own class called BigInt, I can write my own operator<< and use it just like a normal int. This means decreased programming times, which means cash.
    • Syntax equivalence.
      Example: It's very easy to redirect output:
      Code:
      ostream& out = cout;
      out << "rewr";
      //..
      out << var;
      If I want to redirect the output to a file, for example, I only have to change one line of code.
    • Code readablilty. Code with << and >> looks alot nicer and cleaner: Info


    But surely it must be OK to use *printf in such small example like this? No! Why learn a less useful way when there's a better way.
    C++ is about OOP. If you don't like OOP, use C, but don't claim that your code is good C++ code, it's not. This is a C++ forum.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  2. #17
    C > C++ duders ggs's Avatar
    Join Date
    Aug 2001
    Posts
    435
    bigInt_string(), lol
    .sect signature

  3. #18
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    BigInt.string() doesn't work if you'd like source-compability with the built-in type int.

    operator char*() has disadvantages, too.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  4. #19
    C > C++ duders ggs's Avatar
    Join Date
    Aug 2001
    Posts
    435
    lawl

    c++ sux, i bit shift out teh streams
    .sect signature

  5. #20
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Originally posted by ggs
    lawl

    c++ sux, i bit shift out teh streams
    Can anyone translate that for me?

  6. #21
    C > C++ duders ggs's Avatar
    Join Date
    Aug 2001
    Posts
    435
    Someday, you will write a program. It will work, but there will be a problem in your code. You won't know why it works, and you won't be able to fix it, despite all your efforts. When that day comes, i want you to look back and remember this, that you always had a choice.
    .sect signature

  7. #22
    choice of what?

  8. #23
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Originally posted by ggs
    Someday, you will write a program. It will work, but there will be a problem in your code. You won't know why it works, and you won't be able to fix it, despite all your efforts. When that day comes, i want you to look back and remember this, that you always had a choice.
    Sorry, you make no sense. You're bound to have more subtile errors in C than in C++ no matter how careful you are. Also, I doubt you have any clue of what my/Sang-drax's/anyone elses coding ability is, so how can you make such predictions?

  9. #24
    C > C++ duders ggs's Avatar
    Join Date
    Aug 2001
    Posts
    435
    You don't understand your question.
    .sect signature

  10. #25
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Get lost, troll.

  11. #26
    :flame-war:

  12. #27
    C > C++ duders ggs's Avatar
    Join Date
    Aug 2001
    Posts
    435
    Heh, i'm just the messenger. Your language will destroy you!
    .sect signature

  13. #28
    what are you smoking? do you use basic or something?

  14. #29
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Lurking since 1998
    Plz continue.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  15. #30
    C > C++ duders ggs's Avatar
    Join Date
    Aug 2001
    Posts
    435
    One more thing to say, lol:

    if you're using C++ for reasons such as ``array safety'' and other memory leak preventions, you might as well use a language like SML. It's _faster_ in many cases, completely memory safe. A guy I know from irc wrote me a permutation program in 5 minutes with two lines of SML code. It took me half an hour (forgive my incompetence) to write the working plain C equivalent, and when it was done, it only barely beat it speed-wise. C++ is a sort of mid-of-the road language, compromising in all directions but not fully satisfying all. Although, I used C++ in my most incompetent years of programming and thus my judgement of it is a bit colored, I think that you should let people use the simplest form, even if it's a C function, so that they can discover the power of whatever themselves. Misconceptions hatched by the wise, but incomplete words of more experienced programmers can cost a lot of wasted time for newer programmers.
    .sect signature

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. String Concatenation Using Pointers No strcat()
    By oviang in forum C Programming
    Replies: 4
    Last Post: 12-07-2007, 10:31 AM
  2. printing arrays with concatenation
    By derek23 in forum C Programming
    Replies: 1
    Last Post: 07-17-2005, 03:02 AM
  3. concatenation
    By rose2626 in forum C++ Programming
    Replies: 10
    Last Post: 04-25-2003, 01:27 PM
  4. queue concatenation
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 04-02-2002, 06:35 AM
  5. integer concatenation with string again...
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 03-11-2002, 06:36 PM