| We hope you enjoy your visit. You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you are already a member please log in to your account to access all of our features: |
- Pages:
- 1
- 2
| Starting with C++; For all of us beginners in C++ | |
|---|---|
| Tweet Topic Started: Jul 12 2008, 01:22 AM (1,630 Views) | |
| Gandalf20000 | Jul 12 2008, 01:22 AM Post #1 |
![]()
Geek
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Since almost all of us here are beginners with C++, I thought I'd give a tutorial for getting started with C++. I don't know much, but I know some. C++ Basics:
Here's a basic program, with plenty of comments to help you out. When you're finished, if you've done it right, it should say, "This is my first C++ program!"
This concludes my tutorial (for now). If you need more details, I'd be happy to go more in depth. Edited by Gandalf20000, Aug 21 2008, 04:38 AM.
|
![]() |
|
| Mauro | Jul 12 2008, 11:25 AM Post #2 |
|
DirectX - WinAPI Programmer
![]() ![]() ![]() ![]() ![]() ![]()
|
mmh that says, "This is my first C++ program!" you forgot the "//" ^^ (since some peple only copy-and-paste the code... btw good ![]() |
| Programming c++ and directx | |
![]() |
|
| Rixeno | Jul 13 2008, 01:10 AM Post #3 |
![]()
Teo-Carliss
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Yeah, it's almost like the "Hello World" (Actually, it is the same thing, just different "quote")... At least here it explains some stuff, other sites only say to COPY-PASTE-COMPILE-RUN-DONE... |
|
Report spam the nanosecond you see it. Ninjas are everywhere, for all you know there are eleven behind you right now, including me... | |
![]() |
|
| Gandalf20000 | Jul 13 2008, 01:22 AM Post #4 |
![]()
Geek
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
It is a lot like the "Hello World!" program. However, I wrote this from scratch, no copying, simply what I've learned. I can give you guys another program in the tutorial if you want. |
![]() |
|
| harkathmaker | Jul 13 2008, 01:59 AM Post #5 |
|
Persistent Enquirer
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Is it required to place a return statement? Or is it "good coding"? |
![]() |
|
| Rixeno | Jul 13 2008, 02:01 AM Post #6 |
![]()
Teo-Carliss
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
No, I'm not saying it is, it just reminds me of the "Hello World" example because of the simplicity :P. Although the "Hello World" example used different functions from only one header, unlike three. But yeah, it just made me think of that, sorry if it was offensive
|
|
Report spam the nanosecond you see it. Ninjas are everywhere, for all you know there are eleven behind you right now, including me... | |
![]() |
|
| Gandalf20000 | Jul 13 2008, 02:37 AM Post #7 |
![]()
Geek
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Yeah, I used 3 headers because those are the headers I learned C++ with. I don't know what they do exactly (And I really don't care. ), so I included all 3 of 'em. I wasn't offended you thought it was like the "Hello World" program. I think it is as well.
|
![]() |
|
| Dr. Best | Jul 13 2008, 02:39 AM Post #8 |
|
Administrator
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
If the function does not have void as return type (which implies that there is no return value), it always has to contain a return statement. It should also have return statements placed so that some return statement is reached in every case. Otherwise you will get a warning. A little example on this. The following piece of code would result in a compiler warning, because it may be that no return statement is reached:
The following code would not result in a warning:
P.S.: Nice tutorial. The example application really is very similar to a Hello World application, but this is always a good start. Anyway here are two small suggestions how it may be improved: - Your description of the using namespace keyword is a bit misleading. Namespaces are a technique to avoid naming conflicts. Many libraries place all of their content in a namespace. If the library includes a function called foo() and useses the namespace bar the client would have to write bar::foo() to access this function. The :: resolves the namespace. The advantage of having foo() in a namespace is that the client may specify another function called foo() then. It would not result in a conflict, since the compiler can distinguish between the foo() from the library and the foo() specified by the user through the different namespaces. But if you are using very many functions from a particular library you may find it buggy to write something like bar:: all the time. For this reason you may tell the compiler that you want everything from a particular namespace to be in your namespace. To do so you use using namespace. - You should add float to your list of data types. double is a 64-bit floating point value, while float is a 32-bit floating point value. Usually float is used more often, since 32-bit are usually precise enough. All 3D APIs you will find out there will work almost exceptionally with float. |
![]() |
|
| Bazza | Jul 18 2008, 04:13 PM Post #9 |
|
Forum God
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
yay ive made a program that can type words. now if only i can find some one that actualy wants to read...... |
| My instinct is to hide in this barrel, like the wily fish. | |
![]() |
|
| Nextmastermind | Feb 24 2009, 04:30 AM Post #10 |
|
Forum Leader
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Nice...Now I'm off to find out how to get C++... |
![]() |
|
| skarik | Feb 24 2009, 04:59 AM Post #11 |
|
kitten eating scum
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Try Miscrosoft Visual Studio 2005 or 2008. |
| Blog|EHS | |
![]() |
|
| Nextmastermind | Feb 24 2009, 11:36 PM Post #12 |
|
Forum Leader
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Free? If not, how much? |
![]() |
|
| sharlowidalot | Feb 25 2009, 01:05 AM Post #13 |
|
Member
![]() ![]() ![]() ![]()
|
Free, download Here i dunno where 2005 is
|
![]() |
|
| Nextmastermind | Feb 25 2009, 01:45 AM Post #14 |
|
Forum Leader
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
I'm guessing I download the game developers kit? (Dark GDK) |
![]() |
|
| skarik | Feb 25 2009, 02:09 AM Post #15 |
|
kitten eating scum
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
NO. Download the Visual Studio. Here's 2005 if 2008 crashes often for you: http://www.microsoft.com/express/2005/ Don't use GDK, use some other engine. Hell, mod Half Life. That's fun to do, and it helps lots with understanding of arrays and pointers. Edited by skarik, Feb 25 2009, 02:10 AM.
|
| Blog|EHS | |
![]() |
|
| Go to Next Page | |
| « Previous Topic · Tutorials · Next Topic » |
- Pages:
- 1
- 2






![]](http://z1.ifrm.com/static/1/pip_r.png)





), so I included all 3 of 'em. I wasn't offended you thought it was like the "Hello World" program. I think it is as well.
9:01 PM Jul 11