C++ is often thought of as a scary language to start learning. In this meetup of the Malmö C++ User Group we will go over a short introduction of the language and go over many resources on how to get started in the world of C++
vocabulary and set of grammatical rules for instructing a computer or computing device to perform specific tasks.” - https://www.webopedia.com/TERM/P/programming_language.html
vocabulary and set of grammatical rules for instructing a computer or computing device to perform specific tasks.” - https://www.webopedia.com/TERM/P/programming_language.html Programming: “The process of writing computer programs.” - https://www.webopedia.com/Programming
vocabulary and set of grammatical rules for instructing a computer or computing device to perform specific tasks.” - https://www.webopedia.com/TERM/P/programming_language.html Programming: “The process of writing computer programs.” - https://www.webopedia.com/Programming Programmer: “The poor soul that has to do all of this work” - me
or low level languages. I want to call all of them “High Level Languages”, it’s just how high it is, because no language (not even assembly) perfectly describes what is happening on your processor.
or low level languages. I want to call all of them “High Level Languages”, it’s just how high it is, because no language (not even assembly) perfectly describes what is happening on your processor. But that’s just me.
software development. A very high level approach Just start doing stuff, don’t explain the guts. Similar to learning to drive a car, just press the pedal, don’t explain what is going on.
software development. A very high level approach Just start doing stuff, don’t explain the guts. Similar to learning to drive a car, just press the pedal, don’t explain what is going on. A very low level approach Don’t start programming, explain all the nitty gritty details. Similar to learning math, you learn all these methods and types of mathematics before you can start applying them.
bit of a different approach A constructivist approach We’re going to “create core C++ language features” as soon as we have a problem that this feature solves.
purpose is to solve a problem. So let’s look at the language and we will ONLY introduce a feature when we stumble upon a problem. And since I don’t have that much time, I’m going to focus on the core language.
a number. Everything. Even text. So we will start with focusing on numbers. You might have heard that numbers in computers are stored as binary (0101010) but let’s focus on normal whole numbers. Called integers. No fractions, just simple positive or negative numbers.
the value of itself. So we can represent the number. 5 We can add a number with another number 5 + 2 We can subtract, multiply and divide (division will round down)
when the addition is done, but then what, now we’re just left with the number 7. What if I want to add 3 to the number 7? (5 + 2) + 3 Ok, but this can get out of hand quick.
when the addition is done, but then what, now we’re just left with the number 7. What if I want to add 3 to the number 7? (5 + 2) + 3 Ok, but this can get out of hand quick. Problem: What if I want to add some numbers together and then later on add some more numbers?
storing data (numbers) to be used later. They need to have a name so you can reference them later. The name is given by you. numberOfStudents = 4 numberOfStudents = 5 numberOfStudents = 4 + 2
storing data (numbers) to be used later. They need to have a name so you can reference them later. The name is given by you. numberOfStudents = 4 numberOfStudents = 5 numberOfStudents = 4 + 2 = is not equals but assignment. Think of a variable as a box, you name the box and put stuff in it (a number)
numberOfStudents + numberOfTeachers The calculation on the right hand side of totalClassSize is done first. Think of it like this. totalClassSize = numberOfStudents + numberOfTeachers
numberOfStudents + numberOfTeachers The calculation on the right hand side of totalClassSize is done first. Think of it like this. totalClassSize = numberOfStudents + numberOfTeachers totalClassSize = 5 + 2
numberOfStudents + numberOfTeachers The calculation on the right hand side of totalClassSize is done first. Think of it like this. totalClassSize = numberOfStudents + numberOfTeachers totalClassSize = 5 + 2 totalClassSize = 7
biggest/smallest number we can store? Depends on your computer What do you mean depends on your computer? Is it 8bit, 16bit, 32bit, 64bit? Problem: What a number is depends on your computer. How can we be more specific so there is no confusion?
to 127 either true or false nothing Types A type is a way to tell the programming language what you are going to put into the variable. (For these cases, we are going to assume you are using a 32 or 64bit computer) int short char bool void
when you use it. Only when you want to make a new variable. int numberOfStudents = 5 int numberOfTeachers = 2 int totalClassSize = numberOfStudents + numberOfTeachers
when you use it. Only when you want to make a new variable. int numberOfStudents = 5 int numberOfTeachers = 2 int totalClassSize = numberOfStudents + numberOfTeachers Now we know what the biggest number we can store, no confusion there.
to cram all the code I can into as few lines as I can, so I can read it like a book! int numberOfStudents = 5 int numberOfTeachers = 2 int totalClassSize = numberOfStudents + numberOfTeachers
to cram all the code I can into as few lines as I can, so I can read it like a book! int numberOfStudents = 5 int numberOfTeachers = 2 int totalClassSize = numberOfStudents + numberOfTeachers Problem: How can the programming language know where one statement ends and another begins
mark when a statement ends. int numberOfStudents = 5; int numberOfTeachers = 2; int totalClassSize = numberOfStudents + numberOfTeachers; Now you can remove all newlines if you want, but remember, code is for you to read, the computer does not read it like you do.
is great and all. But it’s kinda linear. I want to add another teacher to the classroom if the number of students is over 10. But there is no way for me to do this with only variables.
is great and all. But it’s kinda linear. I want to add another teacher to the classroom if the number of students is over 10. But there is no way for me to do this with only variables. Problem: How can we run code only if a specific criteria is met?
variables with an if statement. int numberOfStudents = 11; int numberOfTeachers = 2; if(numberOfStudents > 10) { numberOfTeachers = numberOfTeachers + 1; }
variables with an if statement. int numberOfStudents = 11; int numberOfTeachers = 2; if(numberOfStudents > 10) { numberOfTeachers = numberOfTeachers + 1; } If the question inside the ( ) is true, then the statement (or statements) between the { } is executed. Otherwise we skip over it.
statements between the { } until the question becomes false, you can use while instead of if int sum = 0; int valueToAdd = 3; while(sum < 10) { sum = sum + valueToAdd; }
statements between the { } until the question becomes false, you can use while instead of if int sum = 0; int valueToAdd = 3; while(sum < 10) { sum = sum + valueToAdd; } When we reach the bottom of the }, we jump back up to the while and ask the question again. Forever, until it is false. Then we jump over it.
writing the same code again and again for each classroom? I’m going to make a mistake somewhere in this mess, I have 10 classrooms and all sorts of other conditions I have to uphold.
where you can define a set of statements and wrap them in a nice little package and give it a name. int add(int numberA, int numberB) { return numberA + numberB; }
where you can define a set of statements and wrap them in a nice little package and give it a name. int add(int numberA, int numberB) { return numberA + numberB; } A function can then be used anywhere in the program (after it has been defined) to perform the action and then store it in a variable.
before, for the teacher and place it in a function. int GetTeacherCount(int studentCount) { int numberOfTeachers = 2; if(studentCount > 10) { numberOfTeachers = numberOfTeachers + 1; } }
before, for the teacher and place it in a function. int GetTeacherCount(int studentCount) { int numberOfTeachers = 2; if(studentCount > 10) { numberOfTeachers = numberOfTeachers + 1; } return numberOfTeachers; }
always have 2 variables, one for the teacher count and one for the student count, can’t I just group them together somehow? Problem: What if I want to have 100 classes, is this then going to turn into a very long file? I don’t want to write all that!
this language https://www.learncpp.com/ https://www.learn-cpp.org/ https://www.udemy.com/free-learn-c-tutorial-beginners/ And not only for C++, many of the concepts we have talked about apply to many other programming languages. The idea is usually the same but it might be written differently.
write code? Well, to get started you need just a computer and internet. There are so many online tools you can use as a way to kickstart your education. http://www.cpp.sh https://www.onlinegdb.com/online_c++_compiler https://wandbox.org/ http://coliru.stacked-crooked.com/
Studio: https://visualstudio.microsoft.com/vs/ For mac you have Xcode: https://developer.apple.com/xcode/ And cross platform you have VSCode: https://code.visualstudio.com/ CLion: https://www.jetbrains.com/clion/ Code::Blocks: http://codeblocks.org/
http://meetingcpp.com/ November 15th 2018 in Berlin, DE C++ on Sea: https://cpponsea.uk/ February 4th 2019 in Kent, UK ACCU: https://accu.org April 10th 2019 in Bristol, UK
http://meetingcpp.com/ November 15th 2018 in Berlin, DE C++ on Sea: https://cpponsea.uk/ February 4th 2019 in Kent, UK ACCU: https://accu.org April 10th 2019 in Bristol, UK C++Now: http://cppnow.org/ May 5th 2019 in Aspen, Colorado
that needs to put in the practice It is YOU that needs to try and most likely struggle trying to find a solution to your problem YOU are the driving force here.
that needs to put in the practice It is YOU that needs to try and most likely struggle trying to find a solution to your problem YOU are the driving force here. Programming can be a wonderful craft that empowers you to no end.