Earlier quoted context omitted.
True, but that can be overcome by another function that just gives you an address to put a new item. You would say, for example: *(int *)vector_expand(v) = 2;
This is a super-unclean API, but that's just IMHO. We'll just have to agree to disagree that what you've shown above is an acceptable API for a vector module.
Why C++ is vastly superior to C
121–123 of 123 posts
Re: Why C++ is vastly superior to C
#122Earlier quoted context omitted.
Implicit conversions come to mind. They don't need to interact with anything to be confusing. Consider this program: #include using std::cout; using std::endl; struct C { int x; C(int _x) : x(_x) {} operator bool() const { return 0 != x; } }; struct D { float f; D(float _f) : f(_f) {} operator bool() const { return 0.0f != f; } }; int main() { C c(9); D d(2.0f); if (c == d) { cout g++ 3.4.4 doesn't so much as warn th…
Yes, several people have already piled on. But if the compiler didn't say "Equal", then I would be claim it's confusing/inconsistent. Are you saying that the funtion YOU wrote to convert C/D to a bool shouldn't be invoked when YOU are using C/D as booleans?
But it's confusing that they're being used as booleans at all. They're converted because it will let the types match even though the conversion doesn't make much sense.
Re: Why C++ is vastly superior to C
#123For some things, C++ is better than C. For some things Lisp is better than either, and for yet other things, Python is better than them all. Why are people so insistent on declaring their view is absolutely right, with no arguments, everyone else is wrong, and that one language will rule them all? Trust me. For some things I do, C is vastly superior to C++, but I'm not going to try to convince everyone that C is bett…
C and C++ have considerably overlap in use cases, which is what makes this argument valid. Comparing C or C++ to Ruby or LISP is stupid.
But comparing C or C++ to C# isn't completely off the mark. And comparing C# to Java isn't crazy either. And once you're at Java, there are plenty of cases where a comparison to Ruby or Lisp makes sense.
So anytime a use case starts in Java (web, mobile, and desktop applications), I think there are very good comparisons to be had on which direction to go.