SHORT C++ Tutorial Pt1: The Basics
This may be a little confusing for some people...
Short Tutorial on the [The Basics] of C++.
Hope you enjoy!
FULLSCREEN HERE
There are tons of types of functions, such as bool, etc. And with libraries like <vector> there are functions like say
std::vector<int> func(){// this returns an int vector}
there are generally only 2 types of functions, 'void' and 'int'
Adding on to @DynamicSquid 's comment
Functions can have many return types. you have things like std::string, std::map
instances of your own classes and many many many more from the standard libraries.
@CSharpIsGud But she was referring to the main ones.
@DynamicSquid well you could say that bool and float and double are "main ones".
@anotherthel well sure. I guess it varies though between people and what you do
@DynamicSquid yeah i guess so.
@anotherthel @DynamicSquid the only main one is int 😜
@Highwayman well u could say the only main one is the one u actually need, which yes, is int
@Highwayman i meant main by included so like bool float whatever
@anotherthel ik I was just joking around :P
@Highwayman haha nice one lol :)
@anotherthel you need every primitive type
#C++Gang
there are generally only 2 types of functions, 'void' and 'int'
What about bool?
oh ok ill add that :) @DynamicSquid
@DynamicSquid Well, bool is only in C++. If you are doing C, you can't do bool. However, what I think should be added is char.
@AmazingMech2418 where would you use a char return type?
@DynamicSquid Well, I've at least used the char*
type for strings in C, but the base of that is char
.
@AmazingMech2418 Oh character pointers! I though you were just referring to regular char. Yeah, I guess that's true
@AmazingMech2418 Yeah c is weird im pretty sure you have to include stdbool.h or something
@anotherthel I just use 1 and 0 to represent true and false in C.
@AmazingMech2418 got you up to 100 :)
@AmazingMech2418 oh. i didnt know that i use c++.
@anotherthel C++ also supports 0 and 1 as false and true
oh i just use true false asa its included @DynamicSquid
@anotherthel yeah same, I don't like the look of 1
s and 0
s
@DynamicSquid WOW! That was a lot faster than I thought it would be... I thought it would be like a month until I got 100 cycles. Also, thank you!
@DynamicSquid char's can hold single characters when you don't need a string or a pointer, and char's in C and C++ represent bytes
@CSharpIsGud yeah I know that... were you responding to this comment: "where would you use a char return type?"
For that I meant where would you commonly use a char return type?
@DynamicSquid Anywhere you need to return a byte, or just to represent a character. like a function to read a byte from something
@CSharpIsGud Well yes, I know that, but what I mean by "main" ones are functions with another purpose. I guess it really depends on how you define "main" but for me "bool" is a major one since STL algorithms and stuff. "void" is also a major one. It really depends
I've literally been trying to learn how to print text slow, this repl taught me how to use user input and how to get any key input. Good looks!
glad you liked it! @ChimaNwosu1