Intimidating powered by phpbb
Intimidating powered by phpbb - Free sex chat with strangers without any payment
So now I implemented a destructor and assumed everything was automagically cleaned up, but little did I know, my custom class with constructors and destructors and everything was leaking memory because I was calling a constructor for a variable in a loop.For reasons Yakk explained, C is ridiculously complicated and nontrivial code written in C shows that. In fact C is so complicated that it can still intimidate programmers who have years of experience with it (as thoughtfully indirectly suggested). It might help to not think of it as an OO language, though.
No looping construct is ever used, and no jumps/conditions/loops (other than a logarithmic depth call tree which can be optimized away) are ever used.
My big problem with C is the hidden memory management that doesn't manager everything.
It's not too much of a problem when you are experienced, but when I was taught we were taught about constructors and destructors, but not about overloading the assignment operator.
I realize I don't need to learn all of C if I want to just write my own code, but what if I want to figure out someone else's code?
Have you ever tried to understand a non-trivial C program? I mean, they implement their own dynamic dispatch object system. Lots of C code is nearly impossible to understand without effort, because it does non-trivial things.
Easier methods, like constexpr, have been added to deal with more trivial cases: similarly, concepts lite in C 14 makes some type-checking hackery in C 11 less required: but those are refinements to the machinery. Of course, the longer you work with it the more features you can learn, but it would be pretty much impossible to learn all the little corners of the language first. A working knowledge of how classes work, new/delete, reference arguments, const correctness, a few classes of STL (string, vector, map) and you already have a lot of extra power. but see, to me, C has this sort of simple elegance - the program flow is easy to figure out, and you can usually look at even unfamiliar code, and if you keep at it, you'll eventually figure out what it's supposed to do and how it works.
Also there are some features that you should just avoid, they tend to create more problems than they're you have no problems with C, I see no reason to be afraid. With C , there's all these weird features, rules and quirks you have to know and remember - especially if you want to look at someone else's code and figure out how it works.It is a common adagium that if you define the constructor, you also have to define the assignment operator, so Thesh was in bad luck for not being told that.)*nod*, the rule of 3(5).If you define a non-trivial destructor, you need to define a copy or move constructor, and a copy or move assignment operator, or both a copy and move of both construction and assignment, or =delete them (C 11), or make them private and unimplemented (C 03).Stroustrup created something almost entirely unlike it. It also tends to refuse to mandate safety at the cost of performance, which makes it harder to use: it provides you with bazookas, and doesn't prevent you from aiming at your feet.Many other high level languages do a lot of work to prevent you from blowing off your feet.Oh, and if you still want to learn the language despite feeling intimidated, you could consider every new thing you learn (which will keep happening for decades) a little victory for yourself.(As for Thesh's issue: you can probably best think of C as having semi-automatic resource management rather than hidden resource management.