Another quick note about C versus C++ and OOP.
Take this code for example (C++):
class CMyClass
{
protected:
float m_val[2];
public:
CMyClass();
~CMyClass();
void load(float a, float b)
{
m_val[0] = a;
m_val[1] = b;
}
float add(void)
{
return m_val[0] + m_val[1];
}
float sub(void)
{
return m_val[0] - m_val[1];
}
float mul(void)
{
return m_val[0] * m_val[1];
}
float div(void)
{
return m_val[0] / m_val[1];
}
};
Yes, I know the code above is pointless, but it's just to make an example.
When you use that code like so (C++):
CMyClass myVar;
myVar.load(42.0f, 23.0f);
printf("%.2f\n%.2f\n%.2f\n%.2f\n", myVar.add(), myVar.sub(), myVar.mul(), myVar.div());
Calling myVar.add() or myVar.sub() or myVar.someFunction() is like doing this: someFunction(myVar);
Which is the equivalent of what you would have to do in C, which is just as fast (provided you aren't using something like TinyC or some other random C compiler no one has ever heard of).
Cheers,
-naota
I'm not a dictator to those that do stuff for me by will. Only those who don't.