Thread: Ok so I now know how to do...

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    903
    Quote Originally Posted by CornedBee View Post
    If you want to program in C, then learn C.
    +1

    Might I add that it would be completely stupid not to use std::string in a C++ application where speed is not critical.

  2. #2
    Registered Abuser
    Join Date
    Sep 2007
    Location
    USA/NJ/TRENTON
    Posts
    127
    I'm sorry guys. I don't mean to step on anyone's toes, I accept that this is a *C++* forum, and therefore the threads should revolve around *C++*.

    IMO there is nothing wrong however with learning alternatives to the status quo. I agree, the implementation of std::string is a wonderful thing, and I too wouldn't use anything else in a C++ program where there was heavy usage of *strings*.

    I would say, learn C++ first, before C or any procedural lang. I see less problem with people migrating from OOP to lower-level langs than vice versa.

    One of the first books I ever read on C++ was the one I mentioned. At the same time, I was in my beginning programming classes. In those classes, we used std::string. So I didn't give much credit to the string class the author develops, accept for it taught me something about classes (which I feel is not a bad thing).

    In the other thread CornedBee, you said:
    And how do you know how we learned classes?

    I'm glad to say that I didn't learn classes by having people on the internet make me "consider" brain-dead designs.
    You're right I don't know how you learned classes, but I would venture to say most people don't LEARN classes by designing very useful ones. I can recall one example I learned that was something like:
    Code:
    class cat
    {
        public:
            cat(){ age = 0; }
            void meow(){ cout << "Meow." << endl; }
            void setAge(int a){ age = a; }
            int getAge(){ return age; }
           ~cat(){ cout << "Screeeeeech!  Thud!" << endl; }
    
        private:
           int age;
    };
    Is this a *brain-dead* design as you put it? Almost certainly. But it was one of those *baby-step* designs that helped me learn something about the structure of a class. It's merits I'd say are equal to that of a "Hello World!" program, not particularly useful, except as a learning tool.

    So I would say to the OP, learn the difference between C and C++ (when you see something like <stdio.h>, let that be a hint...) C++ strings are good for C++ but non-existant in C. And almost certainly at some point, you will come across something claiming to be C++ but is really C, and for that reason alone, it might not be a bad idea to know what it looks like.

Popular pages Recent additions subscribe to a feed