At 46 minutes ago, XxJoshxX wrote:
What exactly makes C++ so much harder for beginners than Java?
Here are some examples of C++ code, which speak for themself.
Even something as simple as iterating through a container is pretty complex, and a little confusing looking (unless you are well versed in C++), in C++:
for (std::vector<int>::iterator itr = myVec.begin(); itr != myVec.end(); itr++)
And errors in C++ can easily confuse a beginner.
Take, for example, this code:
int getId() const;
inline int MyClass::getId() const
This will fail to compile and return an "unresolved external" error.
Unless you are already experienced in C++ chances are you will not know what "unresolved external" means, and that code will not appear to have any flaws.
You can also do some very goofy shit in C++ that a beginner would, I imagine, be very perplexed about.
I guarantee that any beginner to C++ thinks that if you declare a member variable as "private" then it cannot be publically accessed, which is demonstrably false:
int getNumber() const;
Foo::Foo() : __mSomeNumber(42)
inline int Foo::getNumber() const
Foo foo = Foo();
std::cout << "Before: " << foo.getNumber() << std::endl;
int* ptr = ((int*)(&foo));
*ptr = 1337;
std::cout << "After: " << foo.getNumber() << std::endl;
Note: don't ever do this.
And I have not even touched on pointers (although I did use one in the example above), something even intermediate-level programmers in C++ struggle with.
C++ is too complex for a beginner.
Advocating that a beginner to programming learn C++ is the same as advocating that a beginner to mathematics learn calculus.