I was just wondering if there is anyway to use "pure C++" seeing as there is no finalized standard for the language, and technically speaking, if I use even one little old-school C function like memcpy, can it still be called "pure C++?" The reason I ask is because for my 3d libraries all of my math operations such as crossproduct, dotproduct, and matrice stuff are not in classes. I don't really see the point of putting mathematical things like vectors and matrices in classes and being forced to overload operators and what not. It leads to too much confusion. Is it wrong to have functions like this?:
m_multiply( matrix m1, matrix m2, matrix dest );
Furthermore, if I choose to do this do I lose all claims of "pure C++?"
Edited by - acw83 on 8/12/00 7:06:31 PM
C++ basically provides higher-level abstraction then C. The main reason for using C++ in my opinion is for reusability, code can be more readable, and OOP is much easier to design. Everything that you can do in C++ can be done in C if you know how, but at the cost of time. C++ makes things easier down the road in some cases. You may make a vector class or a vector ‘struct’ure.
Why Not?
You really think that OOP design is easier than procedural programming? I''ve always considered it a little harder (maybe I just suck at it hehe), but I agree that the benefits of using it are greater.
===========================================
As far as the laws of mathematics refer to reality, they are not certain, and as far as they are certain, they do not refer to reality.
-Albert Einstein
===========================================
As far as the laws of mathematics refer to reality, they are not certain, and as far as they are certain, they do not refer to reality.
-Albert Einstein
First, the ANSI/ISO C++ standard is finalized and has been in a solid state for a while. The only problem is that some compilers don''t bother complying with it completely (ie, MSVC).
Second, I don''t understand why you think operator overloading leads to confusion. Nothing forces you to overload an operator if you don''t want to. You could just as easily write a member function that does the same thing. But most likely, you *should* overload an operator since it''s a lot easier to write something like:
M = M1 * M2;
than write out:
m_multiply( matrix m1, matrix m2, matrix dest );
More importantly, it''s a lot easier to understand the former than the latter. The code for an overloaded operator is no more complex than a normal member function. Just think that instead of a normal function name, you''re replacing it with the name "operator *" because that''s exactly what you''re doing.
You write the function *once*. You use it *many* times. So you should be more concerned with how easy it is to use it than how easy it is to write in the first place.
As for this idea you have of "pure C++", there''s no such thing. Memcpy and other lower level function are as much a part of C++ as they are of C. As a matter of fact, one of my favorite ways to write a constructor for many situations is to use memset.
Second, I don''t understand why you think operator overloading leads to confusion. Nothing forces you to overload an operator if you don''t want to. You could just as easily write a member function that does the same thing. But most likely, you *should* overload an operator since it''s a lot easier to write something like:
M = M1 * M2;
than write out:
m_multiply( matrix m1, matrix m2, matrix dest );
More importantly, it''s a lot easier to understand the former than the latter. The code for an overloaded operator is no more complex than a normal member function. Just think that instead of a normal function name, you''re replacing it with the name "operator *" because that''s exactly what you''re doing.
You write the function *once*. You use it *many* times. So you should be more concerned with how easy it is to use it than how easy it is to write in the first place.
As for this idea you have of "pure C++", there''s no such thing. Memcpy and other lower level function are as much a part of C++ as they are of C. As a matter of fact, one of my favorite ways to write a constructor for many situations is to use memset.
August 14, 2000 07:50 AM
quote: Original post by acw83
I was just wondering if there is anyway to use "pure C++" seeing as there is no finalized standard for the language, and technically speaking, if I use even one little old-school C function like memcpy, can it still be called "pure C++?" The reason I ask is because for my 3d libraries all of my math operations such as crossproduct, dotproduct, and matrice stuff are not in classes. I don''t really see the point of putting mathematical things like vectors and matrices in classes and being forced to overload operators and what not. It leads to too much confusion. Is it wrong to have functions like this?:
m_multiply( matrix m1, matrix m2, matrix dest );
Furthermore, if I choose to do this do I lose all claims of "pure C++?"
Edited by - acw83 on 8/12/00 7:06:31 PM
Forgive the anonymous post, but I don''t have my username/password on-hand at the moment.
Anyway, first answer is that C++ is final, does have a standard. Pick up the 3rd edition of Stroustrup''s guide (IIRC, The C++ Language). The spec can even be downloaded in PDF format for a mere $18.
As for the "am I still pure C++?" question... What you do with C++ is up to you. C++ does not force you to use object-oriented features. OOP would be overkill in certain situations; at such times, I use C++ as "a better C" since it has better typechecking, allows overloaded functions (not just operators), etc. I don''t always use C++ for objects, but it''s still C++.
If you''re asking from a marketing perspective... well, I would never use C++ on consumer-level docs, since it''s meaningless except as a buzzword.
If you need to share code and need to label it either C or C++ so other developers know what to expect... In that case, C++ usually implies classes, but I would say that if a C++ compiler is required, specifiy C++ anyway, even without classes.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement