One obstacle for many students is that you have to deal with the address of variables a lot because there is no pass-by-reference, such as scanf("%d",&i);
Forget the ampersand? instant "segmentation fault" or "general protection fault", you may even get a freeze up.
The fashion item of those days were C++ and OOP. My college professors themselves were new to C++ && they are making a living teaching it. Everybody embraces the ultra boring "The C++ Programming Language" by Bjarne Stroutroup. Thanks to K&R, the trend for any new language is a book named "The Whatever Programming Language".
"+" is a symbol that operating system reserves (so you can't use it as filename). So the file extension is usually CPP (which some people may confuse with the C Pre Processor). I have also seen CXX. You gotta tilt your head 45 degrees to see the +. Just the // comment itself makes it "a better C". Ah, objects are made with adding methods to structs, label it public, private and call it a class! Waita minute, there IS a difference between structs and classes (and students ought to know).
My first complain of C++ was dumping the good old stdio's printf with cout and the wacky stream operator <<. I hate this stupid syntax. Also, pointers are already confusing, and adding reference type with that ampersand doesn't help. Copy constructors are quite ugly if you ask me.
They NEED to learn algorithms and stuff, not objects in the beginning.
The power of C++ (and OOP) comes in when you are using other people's objects!
Someone programmed a windowing form? boom. subclass it you got yourself a form (theoretically)
Someone wrote some useful classes? You can just the methods within. A good string class is God-sent relief for C programmers.
Inheritance is of course important concept of OOP, but if you let people do multiple inheritance, people WILL go wild and descend from 10 parents (no kidding, I've SEEN such thing)
However, C++ then unbearably evolved. See C++ 0x. Templates
Ah, lamda from the functional programming world is now in C++.
OMG, now there is [[base_check]] and [[override]] attributes?
This is getting unbelievably complex (and ugly).
C++ can grow as complex as Stroutroup want, but compilers may not support it, especially Microsoft's compilers.
The programming world is so relieved with Java, grew out of frustration of C++.
In the programming world, if you are frustrated you can create something new. You don't have to conform.
Languages need to be SIMPLE to be effective.
1 comment:
The idea behind the stream operators << and >> is that you don't worry about type. cout some integers? some double? just do it and shove it to the stream.
Don't like the given operators? well, overload them.
C++ should never be a start language for beginners.
Post a Comment