Hmmmm… For a program, I use C++. If I write a library or some other API, I use C. I have tried to use C++ libs that are given by other programmers, and usually it ends up being an ugly mess. Before you endeavor in C++, understand that C++ IS NOT A NEATO FORM OF C!!! It is a completely different way of thinking, and the programming should reflect that. One thing that pisses me off when I read a code written by somebody is this…
class SomeClass
{
int x, y;
SomeClass() { x = y = 0; };
Initialize(int xval, int yval)
{
x = xval;
y = yval;
};
}
The constructor should initialize the function! In this case, there should either be two constructors, one to initialize to zero and one to initialize to the values given. The constructor is there to keep programmers from using uninitialized classes. If we need the class initialized to specific values, then only the specific constructor should be used ( SomeClass(int xval, int yval) ) thus making a declaration such as:
SomeClass sc; // a compile time error
So, if you want to learn C++ from C, then I suggest you read the book “Thinking In C++” and avoid “C textbook adapted for C++” like the plague!
And also, there are those stinking STL classes. I hate them. They are written to handle every possible case, and not all that efficiently. I suggest you write your own template classes so that you know what is in your own code. Also, watch out for operator overloading. For example, in the previous example, we have vectors A, B and C.
C = A * B; // is this a cross product or dot product? We don’t really know, unless we create something else for dot products or cross products. So, lets overload the ‘.’ operator for a dot product.
C = A . B; // Now we are talking about confusing! What happens when we want the x coordinate of A? A.x… or is that the dot product of A and x? Does the variable x exist? Be careful if you want to overload operators, you may very quickly get in over your head. About 99% of the reason why I don’t like to use C++ libs is because operators are overloaded in ways that I cannot foresee. Maybe Im just paranoid, but keep all this insanity in mind.
just my two cents
[This message has been edited by 147-2 (edited 12-16-2002).]