How to code C++?

Triad

Legions Developer
... visual basic 2006 ...
There is visual studio 2012 now...2006 is crazy old.

Muktar, you'll want the Visual Studio 2012 Express edition for C++. Visual Studio is a great program, but it can be a little confusing at first since it has too many features like all Microsoft products. Feel free to drop me a private message if you have questions. I'm actually still using the 2010 version, but just go with the latest version which is currently 2012. The express edition is free, but doesn't have as many features which is completely fine.

If you are wanting something a little simpler, CodeBlocks is a good IDE for beginners. However, give Visual Studio a shot first and see if you like it since that is what is used in the industry.

I can say that both languages are incredibly easy to learn.
C++ is not easy when you start working on real applications that C++ is typically used for. It's a huge language with many features, and it can get complex.

My (limited) experience in C++ is that it takes ages to write the smallest bit of code compared to a higher level language (obviously). So it's great for learning the 'nitty gritty' but not so great if you want to jump in and start making interesting programs. Personally, I find TorqueScript severely infuriating since you have to work off already shoddy code that you have no idea or documentation as to how half of it works.

Python is great for beginners because you don't have to remember much syntax (apart from hitting tab, which it does automatically half the time), once you get the grips and concepts of that, you can look at what 'CPython' (the vanilla Python version) runs on, C. Python also has built in Garbage Collection, which means that it clears the memory you have used once you are not using it anymore, in C this would be your job, this is just one of the aspects in which you need to wrap your head around when learning C++.

Ultimately it comes down to how much time and dedication you are willing to put into this, following YouTube tutorials (bucky is a great) is a good way to start, but I find that I want to go off and figure out my own stuff as I get to grips with the syntax and basic ideas of the language. There are also some great books out there to read when you aren't in front of the PC.
This is the best response I have seen in the thread. A language such as python would be better for a complete beginner since you will see results faster, and be able to focus on the logic of the program rather than the nitty gritty stuff that C++ is full of such as memory management (although you probably won't get to that point for a while anyway). I haven't used python much, but I know it's easy and quick. It has many libraries to make your life easier, whereas in C++ you typically have to go out and find libraries scattered all over the Internet and figure out how to import them into your project.

C++ is a great language to know, but it's a massive language that is complex. You don't really know C++ until you start learning how to manage memory with it. The fact is there are tons of jobs out there for the younger langauges such as Java and C#. C++ is used for the big time games, and real time systems that need to be fast and efficient. Unless you become an expert with the language, you probably won't even use C++ at a job. Games on your phone and tablets are written in languages such as Java, C# and objective-c, or even Javascript. C++ is used for desktop gaming where you have intense graphics and need to be able to take advantage of every ounce of hardware on the machine.

Making games, I suppose. I'm not very sure what the limits of the language are.
C++ can do anything, but it requires a lot of knowledge. Don't start out making games, start with something more simple. Make a basic calculator and then do something harder. If you really want to do games, try hangman, then tic tac toe and then move on to harder stuff such as Tetris. I wrote Tetris my senior year in high school using C++ and SDL. However, it would be much easier to use something like Python, Java, or C#. If you really want to use C++ to make a game, take a look at Qt. It's a really nice cross platform C++ framework that makes your life easier, and I believe it's now possible to port a Qt game to Android and iPhone.

nop, I was told by Altimor, Mabel's TA buddy, that c++ is the only one I should invest my time on.
If all you are going to do in life is make games, then maybe, but if you want to be a successful programmer you need to know more than one language. I think learning a slightly easier language will be more beneficial to you, such as Python, Java or C#.
 

Mukhtar

Member
I think I'm gonna start off with Python. Are there any programs I need for it?
Gonna use this as a guide;
 

Triad

Legions Developer
Yeah, you need to download the Python installer at the link Dabbleh posted.

The good thing about programming is once you learn one language it's much easier to learn other languages since they are all similar. It's just a matter of learning the different syntax for each language.
 

Mukhtar

Member
Yeah, you need to download the Python installer at the link Dabbleh posted.

The good thing about programming is once you learn one language it's much easier to learn other languages since they are all similar. It's just a matter of learning the different syntax for each language.
syntax?
also can you please give me the code for an arc-type projectile that explodes after a certain range in c++ format?
 

WildFire

Warrior of Linux

In computer science, the syntax of a programming language is the set of rules that define the combinations of symbols that are considered to be correctly structured programs in that language. The syntax of a language defines its surface form.[1] Text-based programming languages are based on sequences of characters, while visual programming languages are based on the spatial layout and connections between symbols (which may be textual or graphical).

Edit:

Spoiler, you need maths.
 

Triad

Legions Developer
syntax?
also can you please give me the code for an arc-type projectile that explodes after a certain range in c++ format?
What *Fireblasto* said.

As an example, the syntax for an "if statement" in Python looks like this:

if balance < 0:
# do something

In C++, the syntax for an if statement looks like this:

if(balance < 0) {
// do something
}

As for the projectile code, all it is is an equation that defines an arc. If you've taken some basic math courses yet, just think y = (-x^2) or something like that, but since you are in three dimensions you have another variable. The hard part is the game engine which can take the value from the equation over different time intervals and interpret it as a position in 3D space. I think you may want to wait a little while before you do any of this.
 

Dabbleh

Legions Developer
Oh, I almost forgot. There are two versions of Python that are currently in use. 2.7 and 3.3, these differ slightly in some syntax, for instance the print statement is treated as a function in 3.3, where as in 2.7 it is standalone.

python 2 print statement

Code:
print "helloworld"

python 3 print statement

Code:
print("helloworld")

Now, the other practical difference is one of modules. If you want to have a wider library of modules at your disposal, you want 2.7, however 2.7 is no longer being updated.
3.3 is just the latest, a lot of the well used modules are already converted over. I personally use 3.3 because that is what I have been taught. There are a lot of deep fixes in 3.3 that I don't understand but are probably quite important, so yeah, take your pick.

some more snippets

Code:
def functionName(var1,var2):    #define a function/method and pass it var1, var2
 
  if var1 == var2:    ##equal to operator in an if
    print("helloworld")      ##print statement
  else:      ##else (if operator returns False)
    var1 = input("Enter a var: ")      ##asks for keyboard input
  return var1 ##returns var1
 
var1 = functionName(1,2)
"""calls functionName passing it int(1), int(2)
and assigns the return value to var1"""

Note on strings:
  • " 'hello' " prints as 'hello'
  • triple quotes span multiple lines
helpful functions:
  • dir() #returns the contents of the object in a list format
  • help() #displays an explanation of the given parameter
 
Top