Indeed, OOP using "tricky methods" is a major problem. 😆

[Excerpt from an introductory textbook on computer science.]

#programming #education

This gem a couple of paragraphs later on OOP:

"This approach has magically brought about an evolution in the software world."

Magic. 😆

A couple of pages later, listing characteristics of C++:

I suppose this definition also serves to illustrate recursion. 😀

It's amazing (and sad) how many books and people claim/believe that the terms "literal" and "constant" are interchangeable in programming.

A rather interesting first C++ program. 😢

[From an actual CS intro textbook. No surprise, it doesn't compile in any compliant C++ compiler in any version of C++, all the way back to C++98: https://godbolt.org/z/x4Kc3x8sh]

[Of course, void main works in MSVC but "iostream.h" and unqualified cout?]

#cpp #cplusplus #textbook #introduction

Compiler Explorer - C++

void main() { cout<<"This is first C++ program"; }

Not surprised to see the claim that "C++ is a superset of C" in this book.

Also, C++ programmers should know they're a privileged bunch.

#cpp #cplusplus #teaching

Words fail me, and my worry for students grows. 😢

#cpp #cplusplus #teaching #pointers

Ah yes, we can use the exit function to end a program. I just wasn't expecting to find it discussed in a textbook for a CS intro course, that too about 20% of the way in. 🤦‍♂️

[FWIW, I don't recall ever using the exit function in all my programming.]

#cpp #cplusplus

I don't quite get why intro C++ courses teach arrays, 2-dimensional arrays no less.

In the same vein, why teach null-terminated strings (beyond literals)? They have so many pitfalls that even the authors can't keep things straight. 😢

#cpp #cplusplus #arrays #cstring

Ahem. A C++ void function *must not* include a return statement.

#cpp #cplusplus #teaching #functions

EDIT: please see the reply from @glloyd and my reply to that. I apologize for, in being brief, suggesting that a void function cannot at all have a return statement.
https://elk.zone/fosstodon.org/@glloyd/110299354968932782

Gareth Lloyd (He/him) (@glloyd@fosstodon.org)

@smurthys@hachyderm.io Not quite, return is implicit when flowing off the end of a non-coroutine function with a cv void return type. Also consider early exit. https://eel.is/c++draft/stmt.return

Fosstodon

"Teaching C++ is easy. After all, I know C."

Also, that reason to declare functions: 🤦‍♂️

#cpp #cplusplus #teaching #functions

"You keep using that word "template" in unfortunately incorrect/confusing ways." 😢

#cpp #cplusplus #teaching

At this point, I mean why not just go with this imperative on structs? 🤦‍♂️

#cpp #cplusplus #teaching

Sure, if by "declaration", you mean "instantiation".

#cpp #cplusplus #teaching #structs

I wasn't going to mention the endl issue because most C++ books have that issue. On that front, this book briefly gave me hope that it distinguishes between '\n' and endl, but alas that lasted only two pages.

The book uses \n for newline exactly once, then mentions endl, and it's all endl from then on. 😢

#cpp #cplusplus #teaching

For context, the aforementioned textbook for an intro CS course 👆 was first published in 2014 and revised in 2018.

#cpp #cplusplus #teaching

@smurthys maybe thinking of
typedef struct foo {} foo;
@PeterSommerlad Not even remotely. The book goes nowhere near that sophistication.