T
Tony
benben said:This is not true. OO in its very nature is procedural. And don't forget
the design of C++ tried very hard NOT to force people thinking in any
certain paradigm in particular (such as OOP.) In addition, C-compatibility
is important therefore anything that easily breaks C programs will not be
considered.
I'm not sure why so many people respond with thoughts constrained to "it
has to be one way or the other". Can you say major paradigm?
Seriously, you can do all these in the plain old main() easily, and
elegantly. You can do an object-oriented program with main(). The
following program is perfectly fine on me:
#include <vector>
#include "shapes.hpp"
int main()
{
std::vector<shape*> v = load_shapes_from_file("shapes");
v.push_back(new triangle);
v.push_back(new rectangle);
for_each(v.begin(), v.end(), print_shape(window::main_window()));
for_each(v.begin(), v.end(), deallocate);
return 0;
}
If you find it hard to say the above is an OO program, you'd better
rethink.
Well I hope someone will think outside of the box and post an alternative!
Again, C++ is quite more than just a "pure OO language" in that it gives
you freedom to choose what you want.
The point is that C++ supports procedural programming moreso than OO.
(Don't even get me started on the over-emphasis and over use of generic
programming!)
Perhaps a little reading will make my point clearer:
http://www.artima.com/intv/goldilocks.html
http://www.artima.com/intv/modern.html
http://www.artima.com/intv/abstreffi.html
http://www.artima.com/intv/elegance.html
Those are very interesting interviews with stroustrup and in my opinion
quite insightful.
If you're just getting started I guess they would be. Nice to review at
other
times too perhaps, but there's probably more interesting reads elsewhere
(like USENET maybe!).
Tony