If you want to call a built-in datatype of C++, that's up to you, but for intents and purposes, they're the same in C and in C++. Objects do not ever require extra space unless they use virtual functions. Nonvirtual function calls are done just like in C. There is no overhead in creating and using built-in datatypes (or even userdefined types with nonvirtual member functions).
Originally posted by SAMSAM
dont you think by representing every number as an
object ,and instatiating it you are creating a unneeded
each number requires more mem as an object. doesnt it?
wouldnt each calling of an object create additional
That's because you literally can't do that in C without manually making a vtable (or some other way of forcing the proper function call). This is one of the features I was talking about where it makes no sense to compare to C because there is no equivalent to it in C. What it comes down to is if you wanted to simulate virtual functions in C, you'd have to manually create and manage your own vtables and do explicit pointer casting, and still not get the benefit of an explicit hierarchy and simple syntax. Your code would not most-likely not be any faster, either. Just a hell-of-a-lot less readable.
an example I was told that comes with some overhead was with inheritance and virtual methods, that the compiler has to check the v table to make sure the correct functions get called and stuff like that, but it really isn't a big deal.
No, simply because of compiler differences, etc. as well as the fact that you explicitly said OO C++. Why not just use the procedural portion of C++ if you wanted an accurate comparison. You could usually even use exactly the same syntax. If you don't use the procedural portion of C++ then you're just going to be comparing two completely different things so a test would prove nothing. Either way, you're not going to get truely accurate results, and besides, once again, the languages themselves are not "slower or faster" so any tests you do only represent the compiler you're using and your system, not the language.
You know, even though many people may disagree, C/C++ are still high level languages. Since I have registered to the CBoard I've seen numerous arguements about the speed differences of C and C++. I think that we should put them both to the test, with lets say... 200-500 million iterations of some kind? with different kinds of situations. So we could compare exact code, then OOP C++ with C, etc. Then when compiling we would have to make sure that all of the same compile options are selected, etc. There might be some websites with 'statistics' of some kind, but if we do it ourselves then we will all know the kind of sacrifices we give up when using C++ rather than C, and C rather than C++. Does this sound like a good idea?