• C++ Beginner
    45 replies, posted
  • [QUOTE=Behemoth_PT;35950793]That's why I recomended the usage of macros in small functions instead of big ones. Because with macros, if you have an error or mistake it will be a pain in the ass to try to figure it out. [/QUOTE] A small pain in the ass is still a pain in the ass. I gotta lube up and everything. It stinks. [QUOTE=Behemoth_PT;35950793]Also I don't use any debugger. Where I study they just want us to use the fedora text editor and the console, and that's it. So basically when we get a segmentation fault, it's chaos.[/QUOTE] I hate to go ad hominem on you, but this is simply ridiculous. Either the place teaching you this has absolutely no competency at all, or you're grossly misunderstanding their teachings. [QUOTE=Behemoth_PT;35950793]I was just giving a useful tip because there is no harm in using macros as substitutes for such small functions. As for bigger and more complex functions, absolutely, use functions![/QUOTE] No, it's just bad advice. Use macros only when absolutely necessary. If you can replace a macro by another construct while still meeting performance and readability requirements, do it.
  • Why even trying C++ when you can do what you can do in C++ in C? Why not write Entity_SetHealth(Entity *this, int health) instead of Entity->SetHealth(int health)?
  • [QUOTE=SiPlus;35953338]Why even trying C++ when you can do what you can do in C++ in C? Why not write Entity_SetHealth(Entity *this, int health) instead of Entity->SetHealth(int health)?[/QUOTE] yes, and why use template <class T> T function(T something); when you can write out every single case manually?
  • [QUOTE=Icedshot;35953876]yes, and why use template <class T> T function(T something); when you can write out every single case manually?[/QUOTE] I thought a long time about how to answer his post. Let's just say you wrote it more succinctly and with more wit than I could've mustered in one great sentence. Bravo.
  • [QUOTE=blankthemuffin;35951013]Yes it is, define is most definitely a part of ISO C99, I just checked. Section 6.10 might be worth a read. [/quote] That's weird. The book I use mentions #define as a non C command, just an order for the pre-processor to expand an instruction that you want to repeat throughout the code. [IMG]http://images04.olx.pt/ui/20/83/05/1334958568_358717805_1-Fotos-de--Linguagem-C-Luis-Damas.jpg[/IMG] It's not a very good book but it was where I learned C from. I then advanced to other books. Since every instruction in C ends with ; and #define doesn't, that's proof enough. Also when you're typing #, you're calling the pre-processor, not doing any instruction in C. [editline]15th May 2012[/editline] [QUOTE=gparent;35952410] I hate to go ad hominem on you, but this is simply ridiculous. Either the place teaching you this has absolutely no competency at all, or you're grossly misunderstanding their teachings. [/QUOTE] I understand, and I'm no C pro exactly. If I'm wrong then I'm wrong, I don't use much macros myself, because they suck when debugging. I just use them for small mundane operations such as simple sums and such things. And I just started using and comprehending macros a while ago so there you go, I'm no pro myself. The place I'm learning from (my uni) has a policy for helper/debugger programs for beginners. We have 2 programming subjects in the first year, Micro-Processor Programming and Algorithms and Data Structures. In Micro-Processor programming our regent strictly forbids the usage of debuggers and helpers for our learning. For the final assignment what we use it's up to us. In classes, It's just an open fedora console and the text editor because he wants us to learn from our mistakes. Also the type of exercises he gives us in that subject to do in classes are nothing of a coding nightmare so there's no issue in using our limited ressources. They're just for us to understand how things work at first hand and think of how to resolve the problems he puts in our way. Normally the programs that are given to us in that subject are strictly mathematical, like making sequences, mathematical algorithms and such. We do that until cycles. Then from vectors up we program things like tic-tac-toe lottery, saving files in data-structures. You know the 101. In the next C subject things get a little more dificult. We can use debuggers and helpers and we're basically on our own. We create our own libraries and such. I don't know exactly since I'm not making that subject this semester. But this is how things work. I myself don't agree much about how they teach us the programming 101 in our uni, I think it's a huge impact and the regent is a jackass if you ask me.
  • [QUOTE=Behemoth_PT;35964394]That's weird. The book I use mentions #define as a non C command, just an order for the pre-processor to expand an instruction that you want to repeat throughout the code.[/QUOTE] The preprocessor is part of what makes up the C language. There's not much more to it than that. You don't end comments by ';' either, they're still defined in the C programming language. [QUOTE=Behemoth_PT;35964394]But this is how things work. I myself don't agree much about how they teach us the programming 101 in our uni, I think it's a huge impact and the regent is a jackass if you ask me.[/QUOTE] Yeah, no offense but teaching people how to code without debuggers is insane. It's not representative of real programming and only teachers you how to guess what happens in your code rather than see what really happens (Guessing won't detect memory corruption, a debugger will). Seems like they want to teach you how to do more with less but they end up doing the complete opposite in the process.
  • Debugging for me is an integral tool for problem solving. It's much better than going "WELL WHAT'S WRONG WITH MY CODE SOMEONE LOOK AT IT" I can just set a breakpoint, find the offending line and make an educated guess why it's blown up. [editline]15th May 2012[/editline] I can't count the amount of times I've been in the "What do you need help with" thread and seen a problem that was just like "use a freaking debugger, that's what they're there for"
  • [QUOTE=Protocol7;35965887] I can't count the amount of times I've been in the "What do you need help with" thread and seen a problem that was just like "use a freaking debugger, that's what they're there for"[/QUOTE] Using a debugger and understanding what it tells you is a skill in itself. I wouldn't expect beginners to be proficient with it, especially not with C/C++.
  • [QUOTE=Catdaemon;35965986]Using a debugger and understanding what it tells you is a skill in itself. I wouldn't expect beginners to be proficient with it, especially not with C/C++.[/QUOTE] I know, that's why I try to get people to use em. Teach a man to fish and all that
  • [QUOTE=Catdaemon;35965986]Using a debugger and understanding what it tells you is a skill in itself. I wouldn't expect beginners to be proficient with it, especially not with C/C++.[/QUOTE] A skill that saves more manhours than I can even count.
  • [QUOTE=Catdaemon;35965986]Using a debugger and understanding what it tells you is a skill in itself. I wouldn't expect beginners to be proficient with it, especially not with C/C++.[/QUOTE] I wouldn't expect beginners to be proficient with anything if they aren't going to use that thing.
  • You guys are right. And what revolts me the most is that they want us to use fedora. The most annoying and idiotic version of linux. So basically when we have people developing their programs in ubuntu or windows cygwin the program just won't work in Fedora, or when it does it has lots of bugs in it and errors. And who the fuck works on fedora nowadays or even learn C from it? Also when fedora has disk error, if you make a checkdisk, it deletes the var folder where all the our data-bases are saved. It's fucking insane! Our regents are fucking idiots if you ask me. I'm repeating this programming subject this semester (again) because last semester it happened. We made an excellent work worth 16/20 and when we tried it on Fedora it didn't work. The program opened but it didn't open the text file we needed to save in our data-bases. We had 0 after weeks of working on that shit. The funny thing is the teacher told us that it was our problem because we made a define# TEXT_LINES 5000 when there were only 4000 lines in the file. That was insane since we were scanning the file until it had no more arguments. 5000 was just the maximum we established to save memory. The guy just told us the program wasn't working because of that. I don't know, the guys teaching C in my uni are fucking idiots that's for sure. No wonder there's so many people failing at C in my uni.
  • [QUOTE=gparent;35972845]I wouldn't expect beginners to be proficient[/QUOTE] If they were proficient then they wouldnt be beginners :eng101:
  • [QUOTE=Richy19;35980040]If they were proficient then they wouldnt be beginners :eng101:[/QUOTE] Exactly.
  • But when you learn how to use a debugger then you can solve an awful lot of bugs. It's just an invaluable skill.
  • I actually started reading that a few days ago! :D [QUOTE=ief014;35889309]So far from my experience, books have helped me much more than tutorials. This is what I used. Helped me a lot with pointers and references in C++ when I was starting out. [img_thumb]http://freebookgroup.com/media/2011/12/BeginCThroughGameProgram.jpg[/img_thumb][/QUOTE]