Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / Anyone else here learning C/C++?

Author
Message
David R
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: 3.14
Posted: 1st Aug 2005 20:35
Hi, I was just (slowly) learning C++ from internet tutorials, and was wondering if anyone else was learning too.

I've been playing around with quite a bit of code now. For example;
(Read the source before compiling!!)


And the main purpose of this thread, was to ask a very simple question about C/C++, hopefully to anyone who is learning, like me

Are any parts of C++ case sensitive? (such as variable names, function names etc.)

Thanks.


(I didn't post on the programming board, since this isn't very serious, and this stuff is very simple )

[url=www.lightningstudios.co.uk][/url]
Jimmy
21
Years of Service
User Offline
Joined: 20th Aug 2003
Location: Back in the USA
Posted: 1st Aug 2005 20:39
Quote: "Are any parts of C++ case sensitive?"


It all is.

ALL of it.

Even string data.

David R
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: 3.14
Posted: 1st Aug 2005 20:42 Edited at: 1st Aug 2005 20:43
Ok. me bad

The tutorial just leaped straight in, and didn't say anything about that kinda stuff. I knew C# was sensitive, but I wasn't sure about C++.

Thanks for clearing that up Jimmy

[url=www.lightningstudios.co.uk][/url]
Merranvo
19
Years of Service
User Offline
Joined: 24th May 2005
Location: That ^ is a Orange
Posted: 1st Aug 2005 20:45
DON'T COMBIND C with C++

#include <cstdlib>
is never used (far as I can tell)
\n is for the printf() of stdio
you really shouldn't return anything for the main
int main(int argc, char *argv[])
should be int main() you aren't inporting anything to the main function.
Your while loops never end
I consiter it bad practice to put comments outside of main

using namespace std;

when do you use namespace?

Blasting, Shooting, and Maiming. Aspects of Modern Gamming.
Merranvo
19
Years of Service
User Offline
Joined: 24th May 2005
Location: That ^ is a Orange
Posted: 1st Aug 2005 20:50 Edited at: 1st Aug 2005 20:51
while (1==1) {
if (Teh_Number!=28) {
cout<<"You are so rubbish!"<<endl;
}else{
cout<<"Oh yeah! 28 is beautiful!"<<endl;
}

Blasting, Shooting, and Maiming. Aspects of Modern Gamming.
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 1st Aug 2005 20:50
Merranvo, have you ever actually done any C/C++ coding?


"Lets migrate like bricks" - Me
Merranvo
19
Years of Service
User Offline
Joined: 24th May 2005
Location: That ^ is a Orange
Posted: 1st Aug 2005 20:52
yes... a bit, haven't mastered the language though...

Blasting, Shooting, and Maiming. Aspects of Modern Gamming.
David R
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: 3.14
Posted: 1st Aug 2005 20:52
Quote: "#include <cstdlib>
is never used (far as I can tell)"


Yeah, it is, its standard library (I'm using Dev-C++)

Quote: "\n is for the printf() of stdio
"

\n means new-line. What's your point?

Quote: "you really shouldn't return anything for the main"

Its because I was using the return for part of another tutorial, and didn't remove it

Quote: "should be int main() you aren't inporting anything to the main function."

Standard setup by Dev-C++ adds the extra stuff

Quote: "Your while loops never end"

Intentional

Quote: "using namespace std;

when do you use namespace?"

When you learn C++ from a modern tutorial

[url=www.lightningstudios.co.uk][/url]
The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 1st Aug 2005 20:55
@David R:

I don't know what version of c++ you're using. But if you use visual c++ 6.0 then this book is great!(I own it myself since i'm also learning c++).

LINK :
http://www.amazon.com/exec/obidos/ASIN/0764543881/qid=1122918761/sr=2-2/ref=pd_bbs_b_ur_2_2/002-4807219-2458469

That book covers from the beginning(Starting out explaining the IDE!) And then it's just moving on from there. And you will end learning pretty advanced stuff. I ain't finished with it yet. It's over 1000 pages! But if you click the image you can see all the things the book covers.



- The Nerd

Visit PanzerGames here
Jimmy
21
Years of Service
User Offline
Joined: 20th Aug 2003
Location: Back in the USA
Posted: 1st Aug 2005 20:57
Quote: "you really shouldn't return anything for the main"


Yes you should.

Merranvo
19
Years of Service
User Offline
Joined: 24th May 2005
Location: That ^ is a Orange
Posted: 1st Aug 2005 20:58 Edited at: 1st Aug 2005 20:59
Dev-C++, yeah... it does help to know what versions you use. They all have diffrent things going on.

But I was refering to the redundancy. If you want your code to be effecant you really shouldn't have things included that you don't take advantage of.

@jimmy, what are you returning to? There are some issues that Windows cooks up to be annoying, but some compilers can take care of this.

Blasting, Shooting, and Maiming. Aspects of Modern Gamming.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 1st Aug 2005 21:04
I learned just the basics of C++. Unfortunately the only place I went to, to talk to other people that programmed in C++ was in a newsgroup. They were C++ purists. I asked how to color text one time and everybody on there freaked out. They yelled at me about how you can't do color in pure C++ and how i'd have to use an outside source which makes C++ unpure... and therefore shouldn't be talked about in their presence. I did it anyway and posted using ansi codes to change the color... they really went nuts over that.

I had no idea the internet had such nut-balls.
David R
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: 3.14
Posted: 1st Aug 2005 21:07 Edited at: 1st Aug 2005 21:08
@The Nerd. Thanks for the book ref Had a flick through the contents... man that thing covers a ton of stuff!

I have Visual C++ 6, but its only an 'intoductionary' edition, so it show an annoying message each time I start an executable made with it (its pretty much just a demo ) so I've been using Dev-C++. But, I
will however consider buying this book, and then I'll use VS 6.

Thanks again, and good luck with C++! (how far are you through that book?)

@Grog Grueslayer; That is seriously scary I hope I never come across anyone like that

[url=www.lightningstudios.co.uk][/url]
Megaton Cat
21
Years of Service
User Offline
Joined: 24th Aug 2003
Location: Toronto, Canada
Posted: 1st Aug 2005 21:22
I once took a C++ class with a friend. Was pretty brutal, even if all we did was edit a FPS demo...


Need a team? No noob bullshit, visit http://www.teamrequest.com
The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 1st Aug 2005 22:05 Edited at: 1st Aug 2005 22:07
Quote: "Thanks again, and good luck with C++! (how far are you through that book?)"
:

I think i'm a little over page 200 and i have learned pretty much! Many difrent operators, how to make functions, how to make and use pointers, how to make functions passing pointers, of course how to print to the screen and taking user input. How to count how many letters a variable contains(With alot of other string manipulators!). How to make Arrays and also how to pass them through a function and some other stuff. Also the book explains all really detailed! So you actually learn much in it!

Visit PanzerGames here
ionstream
20
Years of Service
User Offline
Joined: 4th Jul 2004
Location: Overweb
Posted: 1st Aug 2005 23:08 Edited at: 1st Aug 2005 23:09
Quote: "DON'T COMBIND C with C++"


No, dont combine C file functions with C++ file stream operators.

To save room, you could just use the 'n' character.



EDIT: And if your looking for a GOOD C++ IDE, check out Codeblocks

Sig changed for lagging up browsers.
Sol462
20
Years of Service
User Offline
Joined: 12th Sep 2004
Location: playing with the spazookeedoo
Posted: 2nd Aug 2005 01:54
I may not be correct, but all the return arguments in main() are boiler-plate code that Windows uses.
Supplementing ionstream: Code::Blocks is a pretty good editor for being freeware. You can use your own plugins with the SDK and choose between Visual C++ 2003, GCC, Watcom, DigitalMars, and Borland compilers, so if something is made for VC++, and you're currently using GCC(compiler Dev-C++ uses),no problem. Just download the Microsoft compiler (free, the IDE costs money) and there you go.

BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 2nd Aug 2005 02:03
That's a nice IDE!

Merranvo was somewhat right in saying you don't need "int argc, char* argv[]" in the main function declaration, though it's nice to include them for console apps so that you can pass your program command line arguments.

And, don't you typically want to return 0 from main so that your program exits with no error codes?


I'm going to eat you!
Merranvo
19
Years of Service
User Offline
Joined: 24th May 2005
Location: That ^ is a Orange
Posted: 2nd Aug 2005 02:18 Edited at: 2nd Aug 2005 02:22
The issue is that he doesn't use them. Why whould I put a extra ton of cement that I don't plan on using? It is bad coding, don't make variables that you are not going to use, and don't include liberarys that you don't plan on using.

return 0; is really pointless, it is only to correct a issue with windows, and I think that it was a older verion of windows. I've used borland on XP and I don't seem to have issues, but that is just one compiler.

Ohh, and making a never ending loop is bad habit, even though it is a joke. for the most part, it will make your program crash everytime you run it (or crash as you try to exit it). It is bad devlopment, you allways need a way out.

Blasting, Shooting, and Maiming. Aspects of Modern Gamming.
ionstream
20
Years of Service
User Offline
Joined: 4th Jul 2004
Location: Overweb
Posted: 2nd Aug 2005 02:42
Yeah, the Codeblocks IDE was written in good old fashioned C++, with wxWidgets. It's stable, and feature-rich.

Also, return 0; lets the program that executed your program (most cases, Explorer.exe or your IDE) know that your program exited OK. For instance, with CodeBlocks, if I use return 1; the log window will say "Warning: Application exited with error code 1."

Sig changed for lagging up browsers.
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 2nd Aug 2005 03:09
Quote: "The issue is that he doesn't use them. Why whould I put a extra ton of cement that I don't plan on using? It is bad coding, don't make variables that you are not going to use, and don't include liberarys that you don't plan on using."


Normally this makes perfect sense...but we're only talking about 2 arguments, 5 bytes total, in a small program. It doesn't make a difference.

Quote: "return 0; is really pointless, it is only to correct a issue with windows, and I think that it was a older verion of windows. I've used borland on XP and I don't seem to have issues, but that is just one compiler."


It's one of those good practice things, a rather bad habit not to include it, just like how you mentioned never ending loops is a bad habit. Though you were sort of harsh on that aspect, whenever I run a console program with a never ending loop it never crashes unless you're doing really screwy things--not just looping a cout statement.
I just click the little X in the top right hand corner of the console window and it goes away, in fact, if you click in the window it will stop the loop so you can get a good look at what's going on.


I'm going to eat you!
TKF15H
21
Years of Service
User Offline
Joined: 20th Jul 2003
Location: Rio de Janeiro
Posted: 2nd Aug 2005 03:32
Quote: "Normally this makes perfect sense...but we're only talking about 2 arguments, 5 bytes total, in a small program. It doesn't make a difference."

Well, it's actually 8 bytes, but I think they're created weather you like it or not as the OS will push the parameters into the stack and the compiler will have to pop em out.
return 0 is a good practice, as it can be usefull for debugging. Besides, all functions have to return something, so it is necessary. Unless you want to use void main() (which some compilers don't like). So keep on returning zero: it's not a windows thing, it's a standards thing.

WarBasic Scripting engine for DarkBasicPro
DC emulator code size: 14.3MB, 553,214 lines
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 2nd Aug 2005 06:02
It doesn't matter if you use int main or void main. If you're going to handle a return then you don't technically need it.

David R - What's with cin.ignore()?

And I found that most programmers combine C with their C++. Even with the commercial game I'm working on we're using sprintf commands to output debug text to the screen. Not the most elegant but (in my opinion) some of those raw commands are faster.


My "everyone else has one so why can't I?" blog: http://www.jeku.com/blog/
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 2nd Aug 2005 07:17
I remember using that in class, found a good explanation after a quick search:

std::cin.ignore() can be called three different ways:

1. No arguments: A single character is taken from the input buffer and discarded:
std::cin.ignore(); //discard 1 character
2. One argument: The number of characters specified are taken from the input buffer and discarded:
std::cin.ignore(33); //discard 33 characters
3. Two arguments: discard the number of characters specified, or discard characters up to and including the specified delimiter (whichever comes first):
std::cin.ignore(26, '\n'); //ignore 26 characters or to a newline, whichever comes first


I'm going to eat you!
Dave J
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 2nd Aug 2005 07:59
Quote: "you really shouldn't return anything for the main"


In that case you should use 'void main', otherwise you'll get a method with a return type that doesn't return anything. Either way, it makes little difference whether you return something or not.


Quote: "I consiter it bad practice to put comments outside of main"


...Right, so you think the entire program should exist within the 'main' method? You're way off.


Quote: "when do you use namespace?"


Namespaces are used so you don't need to type out the object name all the time, i.e. he can now use 'cout' instead of 'std::cout'. A great time saver.


Quote: "To save room, you could just use the 'n' character."


You know why that won't work? Because what happens if you really want your string to end with an 'n'? You need the escape character '\' in all circumstances if you wish to create a new line. In fact, Windows actually looks for a carriage return as well as the line feed: '\r\n', however, it's not nescessary.


Quote: "Ohh, and making a never ending loop is bad habit, even though it is a joke. for the most part, it will make your program crash everytime you run it (or crash as you try to exit it). It is bad devlopment, you allways need a way out."


'Ctrl + C' will break out of the program.


"Computers are useless, they can only give you answers."
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 2nd Aug 2005 22:58 Edited at: 2nd Aug 2005 22:59
Quote: "Namespaces are used so you don't need to type out the object name all the time, i.e. he can now use 'cout' instead of 'std::cout'. A great time saver."

Actually thats just the using namespace command your thinking of. Namespaces are used to group functions/variables/classes under a name.

Tempest - P2P UDP Multiplayer Plugin - 80%
Merranvo
19
Years of Service
User Offline
Joined: 24th May 2005
Location: That ^ is a Orange
Posted: 3rd Aug 2005 03:53 Edited at: 3rd Aug 2005 03:54
Quote: "...Right, so you think the entire program should exist within the 'main' method? You're way off."


Please refrain from that. I never said that you only have 1 function. I said that you shouldn't place comments outside of the functions because you aren't actually commenting anything. Some people will comment extensivily outside their program instead of in it because "it is out of the way", but that is a minority. The real issue is once again, redundancy.

Quote: "he can now use 'cout' instead of 'std::cout'. A great time saver."


I never use that command, and I can still use cout...

Quote: "Normally this makes perfect sense...but we're only talking about 2 arguments, 5 bytes total, in a small program. It doesn't make a difference."


you don't need that library, and that lib will take up alot more space then 5 bytes, i can tell you that.

Quote: "char *argv[]"


I might be wrong, but doesn't this create a pointer in the stack that refers to an array that can be any size, and also creates a memory leak because he doesn't delete it?

an infinite loop crashes the program in sense. It will drain the system resources to print that same line over and over again. I know you can end, break, pause. But you aren't suppose to NEED to do that while running a program. A good program assumes that the user is a idiot, and presents options to the user. But then again, Microsoft is the one who made that happen (windows over dos, or unix).

Blasting, Shooting, and Maiming. Aspects of Modern Gamming.
TKF15H
21
Years of Service
User Offline
Joined: 20th Jul 2003
Location: Rio de Janeiro
Posted: 3rd Aug 2005 04:21
Quote: "I might be wrong, but doesn't this create a pointer in the stack that refers to an array that can be any size, and also creates a memory leak because he doesn't delete it?"

Nope, it creates a pointer but doesn't allocate anything within his responsability to delete. Even if it was supposed to be deleted, any allocated memory left after a program exits is cleaned up by Windows/Linux.

Quote: "an infinite loop crashes the program in sense. It will drain the system resources to print that same line over and over again."

Again, nope. You can leave that program running forever, there is no memory leak or other resources being drained.

Quote: "But you aren't suppose to NEED to do that while running a program."

Does it matter? There is no end user here, just a code sample. Software is like a movie: There's a target audience and this one wasn't intended for the totally computer iliterate. Sure, he didn't need to do that, but he wanted to... big deal. Not like it's harmfull in any way.

WarBasic Scripting engine for DarkBasicPro
DC emulator code size: 14.3MB, 553,214 lines
Merranvo
19
Years of Service
User Offline
Joined: 24th May 2005
Location: That ^ is a Orange
Posted: 3rd Aug 2005 05:35
Quote: "Again, nope. You can leave that program running forever, there is no memory leak or other resources being drained."


I don't mean a memory leak, but it does slow your system down until you close it. But then again, I don't know how much memory the new xp dos is allowed.

Blasting, Shooting, and Maiming. Aspects of Modern Gamming.
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 3rd Aug 2005 06:37
Quote: "an infinite loop crashes the program in sense. It will drain the system resources to print that same line over and over again. "


It depends what the infinite loop does. If it continually creates new objects, then fine it will eventually crash. Outputting text to a console in a forever loop will do NOTHING as the computer is just doing what it's told. Outputting text doesn't allocate memory and leave it without being destroyed.


My "everyone else has one so why can't I?" blog: http://www.jeku.com/blog/
Merranvo
19
Years of Service
User Offline
Joined: 24th May 2005
Location: That ^ is a Orange
Posted: 3rd Aug 2005 06:41
uhh ^

okay, I over use the word "crash". Fine.

but I consiter when a program causes the system to slowdown and that program doesn't do anything that it has caused a crash, really that should be system crash, but it is only because of the program, so... whatever.

End Story, it makes your system slow down.

Blasting, Shooting, and Maiming. Aspects of Modern Gamming.
Sol462
20
Years of Service
User Offline
Joined: 12th Sep 2004
Location: playing with the spazookeedoo
Posted: 3rd Aug 2005 07:21
Quote: "I consider it bad practice to put comments outside of main"

What if you're describing things at the beginning of the source file? Example:
/* Author: Mr. Rabbazabba
Program: Spazuh
Date: 1.12.05
*/
Or when you're documenting a class or function in another source file? They're outside of main(). Do you document that stuff, spazuh?

Merranvo
19
Years of Service
User Offline
Joined: 24th May 2005
Location: That ^ is a Orange
Posted: 3rd Aug 2005 07:26
waste of vertical space. .

Actually I document outside the program. If I am writting a complex program. But unless you are spreading scripts, what is the point of documenting?

Blasting, Shooting, and Maiming. Aspects of Modern Gamming.
Sol462
20
Years of Service
User Offline
Joined: 12th Sep 2004
Location: playing with the spazookeedoo
Posted: 3rd Aug 2005 07:29
If you look back at your code some time later, you look at the documentation to see what you were doing. It often happens that you forget what your code meant, especially if you don't keep a certain style for very long.

Merranvo
19
Years of Service
User Offline
Joined: 24th May 2005
Location: That ^ is a Orange
Posted: 3rd Aug 2005 07:49
no, I meant like

Programmed by: Merranvo
Type: Game
Genera: Shooter
Some other stuff: Blah


I do comment inside the program what lines and things do, but It is a waste of space to simply include something like that ^ for each of the files, with C and C++ I will separate all my functions into header files, and I really don't need that title line in each of them.

P.S. Separating the functions into header files makes it easier on my part on debugging and keeping the source neater, I really don't like it when I have a bunch of functions mashed together into 1 little file. I may forget where a particular function is. With header files if I want to edit a function, I just click on the file with the name of the function, and everything is there.

Blasting, Shooting, and Maiming. Aspects of Modern Gamming.
Sol462
20
Years of Service
User Offline
Joined: 12th Sep 2004
Location: playing with the spazookeedoo
Posted: 3rd Aug 2005 07:53
I meant that if you comment inside said functions that are in seperate source files, technically you are commenting outside of main().

Merranvo
19
Years of Service
User Offline
Joined: 24th May 2005
Location: That ^ is a Orange
Posted: 3rd Aug 2005 07:57 Edited at: 3rd Aug 2005 08:19
I did say that didn't I...
I really need to start working on what I type. I type one thing, but have some little detail wrong. I always miss something, no matter how many times I might read something.

Blasting, Shooting, and Maiming. Aspects of Modern Gamming.
Dave J
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 3rd Aug 2005 09:32 Edited at: 3rd Aug 2005 09:35
Quote: "Actually thats just the using namespace command your thinking of."


I'm obviously explaining within the context of the above program. That's when namespaces are 'used'.


Quote: "Please refrain from that. I never said that you only have 1 function. I said that you shouldn't place comments outside of the functions because you aren't actually commenting anything. Some people will comment extensivily outside their program instead of in it because "it is out of the way", but that is a minority. The real issue is once again, redundancy."


Refrain from what? You said it was bad practice to put comments outside of 'main', if I created another method then I'd have to put the comments outside of main, therefore, logical conclusion would establish that to follow 'good practice' I would have to include all my code within main. However, enough technicalities, I will now follow your new statement that you shouldn't put comments outside of a 'function'.

This is incorrect anyway, if I wish to comment on the overall function of the specific file or program then I would place it at the very top of the file above and out of the 'main' method (and any other methods/classes). Similarly, if I wish to comment on the method's function (which should be mandatory), then I would place the comments above the method definition (and outside of the method body itself), the same goes for classes. I hope you don't take this the wrong way, but I'd like to make sure new users don't get the wrong impression because what you're implying as 'bad practice' and 'redundant' is actually the right thing to do.


"Computers are useless, they can only give you answers."
Merranvo
19
Years of Service
User Offline
Joined: 24th May 2005
Location: That ^ is a Orange
Posted: 3rd Aug 2005 10:32
Quote: "I did say that didn't I...
I really need to start working on what I type. I type one thing, but have some little detail wrong. I always miss something, no matter how many times I might read something."


which was in referance to

Quote: "
I meant that if you comment inside said functions that are in seperate source files, technically you are commenting outside of main()."


But I do leave out too much, I am such a lowsy poster!

The Bad Practice comes in when people start to do more then simply tell what the function is, and what the vars are. But, yt depends on the person really, in my opinion; most of the commenting belongs where things are occuring, not listed above the codebrackets (for lack of broader term). Even then I like to have the simple what the function is and variables inside it, someone needs to start reminding me everyday that it I am NEVER clear when I keep linking to context (What I said was I consiter it bad practice, when I really should have used In My Opinion.) or I can do this

#define consiter In.My.Opinion

But I do stand firm on the fact that you shouldn't get into the habit of including liberarys or variables that you never use. Yes, it only takes up a little space with vars, but if you have a complicated source you don't want to say "what is this var for" look though it for a while before you realize that it does nothing. Even if you have it declared only because you are going to build a function (in main or outside [condition series, i guess you could call it] ) later because then you have it there but may forget that it was there for that reason, or forget what it was for.

It probally is just me. Then again, I like to build things in peices rather then abstract building (where you get the bones for more than 1 aspect up) I work 1 thing at a time.

But libarys have 1 rule, use it or waste space. I don't know how big the cstdlib is, but I don't see any other functions being used that aren't in iostream. So you have a libary included that declares mabey 100< functions, and it is doing nothing. I just don't see the logic.

Blasting, Shooting, and Maiming. Aspects of Modern Gamming.
Sol462
20
Years of Service
User Offline
Joined: 12th Sep 2004
Location: playing with the spazookeedoo
Posted: 4th Aug 2005 04:16
As they say, "Good code comments itself."

BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 4th Aug 2005 05:41 Edited at: 4th Aug 2005 05:49
Quote: "But libarys have 1 rule, use it or waste space. I don't know how big the cstdlib is, but I don't see any other functions being used that aren't in iostream. So you have a libary included that declares mabey 100< functions, and it is doing nothing. I just don't see the logic."

Normally you'd be right, but seeing as how we're looking at a 530KB exe, nobody really cares.

Quote: "I never use that command, and I can still use cout..."

That's probably because you're using #include <iostream.h>, last I heard it was old and is only kept around for backwards compatibility. Use #include <iostream> and using namespace std; instead.

Quote: "I might be wrong, but doesn't this create a pointer in the stack that refers to an array that can be any size, and also creates a memory leak because he doesn't delete it?"


Typically VC/Windows will delete the memory for you, and the array is exactly 1 + the number of command line arguments. I don't even know if it creates a library (and if so how big it is) or if it's just built into console apps, but considering that all it does is count the number of command line arguments based on spaces and create the array it can't be very large at all.


Quote: "The Bad Practice comes in when people start to do more then simply tell what the function is, and what the vars are. But, yt depends on the person really, in my opinion; most of the commenting belongs where things are occuring, not listed above the codebrackets (for lack of broader term). Even then I like to have the simple what the function is and variables inside it, someone needs to start reminding me everyday that it I am NEVER clear when I keep linking to context (What I said was I consiter it bad practice, when I really should have used In My Opinion.) or I can do this"


Why on earth would you only comment what's happening inside of the function? Imagine some person just commented the function name and the list of variables and a very generic description of what it does. Now imagine that this guy wrotes hundreds of functions and tens of thousands of lines of code, and commented all functions and files in this vague method. Finally, imagine you have been paid to debug it. You would have an idea of where the program is breaking, but because the guy sucked at documentation you'd have to scroll through each of the functions that appear as though they might have what you're looking for instead of telling exactly what they do and how they do it in the documentation above the declaration.
That would suck.

All of the Torque sample project scripts are like that, and it sucks. It took me all of one day to find one little function that I had to edit to include AIs when checking for inventory pickup because the script is so widespread and undocumented.

The author details is standard. If you're working for a company and the software engineer is compiling and finds a bad file he can have a quick look in the author section to find out who to yell at, otherwise he yells at everybody about documenting code, then on his duty roster finds out it was you, then yells at you double time. If you're distributing example or open source code on the internet don't you want to ensure you are clearly defined as the author? Hell, look in the codebase for any random snipped and they're usually clearly marked with authors.

We know it's your opinion, and we would like to tell you that your opinion is wrong. Sorry dude, but do things the way we're telling you and coding will be a lot smoother. And if you major in CS in college or take a C++ code they'll require you to do all these things.


I'm going to eat you!
Merranvo
19
Years of Service
User Offline
Joined: 24th May 2005
Location: That ^ is a Orange
Posted: 4th Aug 2005 05:45
The more times a person does one thing one way the more times that way seems the best way. ~unknown

Blasting, Shooting, and Maiming. Aspects of Modern Gamming.
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 4th Aug 2005 05:48 Edited at: 4th Aug 2005 05:49
"Don't fix what isn't broken." ~Unkown


I'm going to eat you!
Merranvo
19
Years of Service
User Offline
Joined: 24th May 2005
Location: That ^ is a Orange
Posted: 4th Aug 2005 06:41
Exactally... thank you for agreeing with me.

My method isn't broken, it is merly a diffrent aproach.

Blasting, Shooting, and Maiming. Aspects of Modern Gamming.
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 4th Aug 2005 06:59
I think it's broken, read the bit about debugging. It doesn't work out quite well for the debugger, which leads me to believe that it's broken.


I'm going to eat you!
Merranvo
19
Years of Service
User Offline
Joined: 24th May 2005
Location: That ^ is a Orange
Posted: 4th Aug 2005 07:11
Anti-Flamewars Badge...

We just have differing opinions, and our minds work in different directions. In the end it really depends on the person. Just because teacher that says to put the { two lines below the first instance does not make it the best way. You might read it better to have it 5 lines below! Differences over, Let's agree to dissagree.

Blasting, Shooting, and Maiming. Aspects of Modern Gamming.
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 4th Aug 2005 22:05
If you want to program for real in a job setting, you must conform to the standards set out by the employer. Just because you feel that such-and-such method is better than so-and-so, you still must adhere to given ways.


My "everyone else has one so why can't I?" blog: http://www.jeku.com/blog/
ionstream
20
Years of Service
User Offline
Joined: 4th Jul 2004
Location: Overweb
Posted: 4th Aug 2005 22:54
Hey Jeku, you should make your sig image display the IP address of the person who downloads it, to scare the crap out of noobs!

Sig changed for lagging up browsers.
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 4th Aug 2005 22:57
Then you'd get some person saying "oh my god you can hack that mods should be more responsible".

"A book. If u know something why cant u make a kool game or prog.
come on now. A book. I hate books. book is stupid. I know that I need codes but I dont know the codes"

Login to post a reply

Server time is: 2024-11-15 14:55:00
Your offset time is: 2024-11-15 14:55:00