Hot answers tagged

8

I think you're having trouble justifying the study of C++ because of the way that you're thinking about it. If you are aiming towards the practical benefits, then you immediately get to the following trap: neither you nor your students has any idea what languages they will work with in the future, so neither you nor your students have any idea what ...


5

First off, if your students are truly mastering pointers on their first course, hats off to you. That's quite a lot of material to pack into a semester. Structs involve a mess of abstractions not present in anything you mentioned before in your course. What you are doing involves: user-defined types instances, dot-notation, which is syntactically ...


5

There are many reasons for wanting to learn a new language, whether C++ or something else. I'll try to make this general enough to address Timothy Truckle's concerns in a comment, but also the questioner's direct question. If you are a scholar you learn a new language because it gives you some additional perspective on programming that the languages you ...


5

I wouldn't fuss too much over whether a language is "hard" or "easy". There are plenty of reasons to learn a language. Learning for a career is a great reason! Languages are usually organized around certain central ideas. Haskell is a pure functional language, Eiffel is a pure Object Oriented language, and C is designed to reflect very closely what a ...


4

Your question deserves a long discussion, but I will try to narrow it down to few points. First, remember that you are dealing not just with a "compiled language" such as Java or C# (that could be much easier targets for you), you are dealing with C++ that was designed with backward compatibility with C as a killer feature, and C was created in late 70s. It ...


4

Create an object that creates a new file and writes in to it over several method invocations (not just one). Assure that the object has been deleted before continuing (Make the object go out of scope on the stack or delete a reference and let the reference go out of scope.) You need to assure that he file was closed. The destructor is the proper place to ...


4

I want to tack on to Buffy's answer by focusing on one line from your question: "I want him to learn C++,Java,Html" (emphasis added). The bigger question should be "What does he want to learn?" Part of the beautiful challenge that is teaching is getting students to want to learn what we want to teach them. What has your brother shown interest in? What has ...


4

While I would suggest a different language for beginners, I'll take it as given here that the students need to learn C++ and not just programming for general use. In that case, teach them Modern C++. That means C++ versions 14 and 17 and don't bother with anything earlier. To do this find a good book that focuses on those versions (or later if you are ...


4

You've said that having an identical environment for everyone would be an incomplete solution, since students' code could still work "by accident" in that environment. One option would be to provide access to two or more sufficiently different environments which would be the same for everyone; such environments could be provided in several ways, for example: ...


3

Do it in two steps: There are resources for each part. Start by learning how to compile, link, run code, and launch the debugger, from the command line. Then learn how to write make files. You should also read Recursive Make Considered Harmful by Peter Miller. It should direct you away from a lot of common bad practice. When I applied what I learnt from it,...


3

You are teaching a fundamentally low level language. It is intentionally close to the hardware. Initially it was intended as a high level assembly language for one of the early computers of the Digital Equipment Corporation (a PDP-7). So, having chosen that, you might as well teach it according to its design. A struct, fundamentally, is a "structured value"...


3

For make consider O'Reilly book. It is a perfect intro. Honest to goodness. The GDB one is not so much an educational tool, it is a reference, but I doubt you'd find anything which would teach you how to use GDB any better. The GDB learning curve is short and easy. I also doubt that there is a resource dedicated to gcc any better than the online ...


3

Try explaining to your students the concept of a product type using a simple notion of an x,y-coordinate. We can illustrate a notion of pair of (integer) coordinates as an integer array of size 2.  Whenever we need to access the x-coordinate, we access [0] element and y-coordinate, the [1] element, for example. A struct also does this — however, ...


3

There are 2 good examples of patterns where the destuctor is a key. This way you can teach a couple of useful patterns on the way. RAII - Resource Acquisition Is Initiation Rule of 3/5/0 It's easy to give a RAII assignment, just any C style handle that can be released in the end (Like a File handle, windows handle, etc). If they are more advanced, you ...


3

I'm not convinced that the issue is necessarily related to using a language like C, or even cognitive overflow. I think that students often need a number of examples to illustrate a concept to be able to find the paradigm that works for them. Sometimes aspects of the example themselves use things that they cannot immediately relate to from the real world. I ...


3

@Ben said most of what I was about to write. However I have one more thing. The example is terrible. A shopping cart for a shop that sells exactly 3 things, nothing more and nothing less, and never will it change. This is an alien enough concept, to confuse them. They know what a shop is, and this type of shop does not exist. They will try to match the code ...


3

Your student/staff ratio is pretty unfavorable. This makes everything difficult. If you had a few more TAs or could find the schedule time, I'd make one of the TAs the person to handle all such technical issues. It would need to be the one with the highest "geek cred" I think. But debugging stuff shouldn't be the instructor's job. Part of the job of the ...


3

I don't think that an entire Cloze test is practical, and in any case, it does not assess deep understanding well. One problem with longer Cloze examples is that they force the student not only to understand the goal, but also your particular implementation, which will often feel quite foreign to them, even if they are strong students. A further problem ...


2

C++ seems like an awfully steep climb for someone that age with no experience. I'm not sure what educational resources are available directed at that age. I'd suggest that you start out with something more forgiving. Python has been a pretty good choice and has an OO core without quite so many "guns, knives, and clubs" which was an original description of ...


2

I have tried to learn and teach C++, I have seen others try to learn or teach it. I have seen people come out of university, having “Learnt it”. I have seen no success. None of these people have learnt it well, few have learnt it at all. The only exception are those that first learn another OO language. The best OO language to learn first is Eiffel. ...


2

There are a few places C++ (or C, or rust or ...) is more useful than Java[1] because C++ does (what Rust likes to call) "zero cost abstractions". The idea is that C++ gives you the power to be as low level as you want to get, and at the same time as high level as you want to go. Real Time. Note, I didn't say fast. real-time doesn't always mean fast. ...


2

Programming languages are like tools. Different tools are better for different tasks. Hammers are useful for certain tasks, and saws are useful for other tasks. The same is true of programming languages and other programming tools. For example, one construction company might get their wood from a place that only sells full-sized logs, which they then have ...


2

welcome to our community ;) Is learning C++ recommended for beginners? In general, I would suggest that it is not the optimal choice for a beginner, since there are other languages out there that are powerful, widely supported, used in a range of industries and (perhaps most importantly for a beginner) have a simple syntax with powerful features. I am ...


2

I would make it hands on and C-based, with very little OOP in the beginning. You can code in C++ using it as a "better" C. You'd introduce classes by the way without making a big deal of OO stuff. I'd focus on I/O, data structures, particularly, containers such as lists and arrays, and algorithms such as search and sorting. Maybe write simple utilities, e....


2

There are many ways to do this, they basically rely on the "culture" of students and the purpose that they should learn. C++ is a multiple model and not "pure" in any of them, so... Teaching language and realism is a process: start with some courses before the process: Make them know about the two, compilers, etc. do not go into detail, but tell the path to ...


2

You wrote: The first incentive is that the course needs to provide a solid foundation, which includes understanding how things work under the hood and implies teaching pointer, raw array and string, dynamic allocation etc. This is not the only definition of a "solid foundation". I would suggest that your second approach is also a "solid foundation", but ...


2

Consider that computers (the hardware) and programs (the software) are designed and built as a layered system. Each layer defines a complete and consistent model of computing that can be used without any reference to lower levels - except in the implementation. You can program effectively in, say, Scheme, without reference to silicon or to registers or to ...


2

As early as possible in the course, and again when appropriate examples arise, you should "round up the usual suspects." (It's a Dick Tracy reference, but that does not really help.) You could include this as a "sidebar" feature of many classes. And you could have a "crib sheet" listing the most common such mistakes. For example one frequent mistake is ...


2

Small == Old. Modern IDE != Small. However, would Turbo C++ or OpenWatcom work? I believe both have "free" licenses. Caution: your students will get spoiled by how fast Turbo C++ is and then complain about every other compiler in existence. Good luck.


Only top voted, non community-wiki answers of a minimum length are eligible