0% found this document useful (0 votes)
4 views

c++ memories

This document is a comprehensive C++ tutorial that covers the basics of the C++ programming language, including its features, data types, operators, control structures, and object-oriented programming concepts. It also introduces the Standard Template Library (STL) and various data structures like vectors and lists. The tutorial aims to provide a foundational understanding for creating high-performance applications, particularly in game development.

Uploaded by

stiyevefsan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

c++ memories

This document is a comprehensive C++ tutorial that covers the basics of the C++ programming language, including its features, data types, operators, control structures, and object-oriented programming concepts. It also introduces the Standard Template Library (STL) and various data structures like vectors and lists. The tutorial aims to provide a foundational understanding for creating high-performance applications, particularly in game development.

Uploaded by

stiyevefsan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 40

C++ Tutorial

Fehmi UYAR
C++ bilgisayar programları
oluşturmak için kullanılır ve oyun
geliştirmede en çok kullanılan
dillerden biridir
C++ Nedir?
Neden C++ Kullanılmalı?
✔ Yüksek performanslı uygulamalar ✔ C++ dünyanın en popüler programlama
oluşturmak için kullanılabilecek platformlar dillerinden biridir
arası bir dildir
✔ Günümüzün işletim sistemlerinde,
✔ Bjarne Stroustrup tarafından C dilinin bir Grafiksel Kullanıcı Arayüzlerinde ve
uzantısı olarak geliştirildi gömülü sistemlerde bulunabilir.
✔ Programlara net bir yapı kazandıran ve
kodun yeniden kullanılmasına izin
✔ Programcılara sistem kaynakları ve bellek vererek geliştirme maliyetlerini düşüren
üzerinde yüksek düzeyde kontrol sağlar. nesne yönelimli bir programlama dilidir

✔ Taşınabilirdir ve birden fazla platforma


✔ Dil 2011, 2014, 2017 ve 2020'de 4 ana uyarlanabilen uygulamalar geliştirmek
kez C++11, C++14, C++17, C++20 olarak için kullanılabilir.
güncellendi
✔ C++ eğlenceli ve öğrenmesi kolaydır!

✔ C++, C , C# ve Java'ya yakın


olduğundan programcıların C++'a (ya
da tam tersi) geçişini kolaylaştırır.

C++ NEDEN C+
NEDİR? +?
C++ ile Neler Yapılır?

01 Video Oyunları

02 Grafik Uygulama ve Simülasyonlar

03 Ses ve Video İşleme

04 Yapay Zeka ve Sinir Ağları vs.


types of variable description
int stores integers (whole numbers), without decimals, such as 7 or -19
float / double stores floating point numbers, with decimals, such as 19.99 or -7.68
char stores single characters, such as 'r' or 'F'. Char values are surrounded by single quotes
string stores text, such as "How is it going?". String values are surrounded by double quotes
bool stores values with two states: true or false

Basic Data Types


Data Type Size Description
boolean 1 byte Stores true or false values
char 1 byte Stores a single character/letter/number, or ASCII values
int 2 or 4 bytes Stores whole numbers, without decimals
float 4 bytes Stores fractional numbers, containing one or more decimals. Sufficient for storing 6-7
decimal digits
double 8 bytes Stores fractional numbers, containing one or more decimals. Sufficient for storing 15
decimal digits
ASCII
Characters
Arithmetic Operators

Operator Name Description


+ Addition Adds together two values
- Subtraction Subtracts one value from another
* Multiplication Multiplies two values
/ Division Divides one value by another
% Modulus Returns the division remainder
++ Increment Increases the value of a variable by 1
-- Decrement Decreases the value of a variable by 1
Assignment Operators
Operator Same As
= x=7
+= x=x+7
-= x=x-7
*= x=x*7
/= x=x/7
%= x=x%7
Bitwise Operators
Operator Same As
&= x=x&7
|= x=x|7
^= x=x^7
>>= x = x >> 7
<<= x = x << 3

AND OR XOR
X Y X&Y X Y X|Y X Y X^Y
1 1 1 1 1 1 1 1 0
1 0 0 1 0 1 1 0 1
0 1 0 0 1 1 0 1 1
0 0 0 0 0 0 0 0 0
Comparison Operators

Operator Name
== Equal to
!= Not equal
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
Logical Operators

Operator Name Description


&& Logical and Returns true if both statements are true
|| Logical or Returns true if one of the statements is true
! Logical not Reverse the result, returns false if the result is true
C++ ile şartlı ifadeler oluşturup yazılımı yönlendirme

01 If 02 else

03 Else if 04 Short hand if else

C++
Conditions
C++ ile döngü oluşturma komutları

01 while 02 do while

03 for

C++ Loops
isalnum(value) True if character is a letter or a digit

isalpha True if character is a letter

iscntrl True if character is a control character

isdigit True if character is a digit

isgraph True if character is not a space but is printable

islower True if character is a lowercase letter

isupper True if character is an uppercase letter

isprint True if character is a printable character

ispunct True if character is a punctuation character

isspace True if character is a whitespace

tolower Change character to lowercase if it is an uppercase letter

toupper Change character to uppercase if it is an lowercase letter

isblank The isblank() function returns non zero value if ch is a blank character, otherwise
returns zero.
String
Functions capaticy
size() Return length of string
length() Return length of string
max_size Return maximum size of string
resize Resize string
capacity Return size of allocated storage
clear Clear string
shrink_to_fit Shrink to fit

Element access
operator[] Get character of string
at Get character in string
back Access last character
front Access first character
String
Functions Iterators
begin Return iterator to beginning
end Return iterator to end
rbegin Return reverse iterator to reverse beginning
rend Return reverse iterator to reverse end
cbegin Return const_iterator to beginning
cend Return const_iterator to end
crbegin Return const_reverse_iterator to reverse beginning
crend Return const_reverse_iterator to reverse end

String operations
find Find content in string
substr Generate substring
compare Compare strings
String
Functions Modifiers
+= operator Append to string
append Append to string
assign Assign content to string
insert Insert into string
erase Erase characters from string
replace Replace portion of string
swap Swap string values
pop_back Delete last character
Trigonometric and Hyperbolic functions
MATH Functions
cos Compute cosine
sin Compute sine
tan Compute tangent
acos Compute arc cosine
asin Compute arc sine
atan Compute arc tangent
atan2 Compute arc tangent with two parameters
cosh Compute hyperbolic cosine
sinh Compute hyperbolic sine
tanh Compute hyperbolic tangent
acosh Compute area hyperbolic cosine
asinh Compute area hyperbolic sine
atanh Compute area hyperbolic tangent
Exponential and logarithmic functions
MATH Functions
exp Compute exponential function
frexp Get significand and exponent
ldexp Generate value from significand and exponent
log Compute natural logarithm
log10 Compute common logarithm
modf Break into fractional and integral parts
exp2 Compute binary exponential function
expm1 Compute exponential minus one
ilogb Integer binary logarithm
log1p Compute logarithm plus one
log2 Compute binary logarithm
logb Compute floating-point base logarithm
scalbn Scale significand using floating-point base exponent
scalbln Scale significand using floating-point base exponent (long)
Power, rounding and remainder functions
MATH Functions
pow Raise to power
sqrt Compute square root
cbrt Compute cubic root
hypot Compute hypotenuse
ceil Round up value
floor Round down value
fmod Compute remainder of division
trunc Truncate value
round Round to nearest
lround Round to nearest and cast to long integer
rint Round to integral value
remainder Compute remainder (IEC 60559)
nearbyint Round to nearby integral value
Error and gamma functions MATH Functions
erf Compute error function
erfc Compute complementary error function
tgamma Compute gamma function
lgamma Compute log-gamma function

Floating-point manipulation functions


copysign Copy sign
nan Generate quiet NaN
nextafter Next representable value
nexttoward Next representable value toward precise value

Other functions
fdim Positive difference
fmax Maximum value
fmin Minimum value
fabs Compute absolute value
C++ OOP
Class, object, method, constructor, public, private, protected, encapsulation, inheritance, polymorphism, abstraction

Object-Oriented Programming
01 public 02 private

03 protected

C++ Access
Specifiers
MEMORY
MANAGEMENT
C++ iostream objects
Object Description
cerr Hata mesajları için bir çıktı akışı
clog Program bilgilerini günlüğe kaydetmek için bir çıktı akışı
cin Varsayılan olarak konsoldan klavye girdisini okuyan bir giriş akışı
cout Çıktıyı varsayılan olarak konsola yazan bir çıktı akışı
wcerr cerr ile aynıdır ancak char verisi yerine geniş char (wchar_t) verisi çıktısı verir
wclog clog ile aynıdır ancak char verisi yerine geniş char (wchar_t) verisi çıktısı verir
wcin cin ile aynıdır ancak her giriş karakterini geniş bir karakter (wchar_t) olarak
yorumlar
wcout cout ile aynıdır ancak char verisi yerine geniş char (wchar_t) verisi çıktısı verir
C++ FILES
C++ FILES MOD

Mod Description
ios::app ✔ Yazma amacıyla açılan bir dosyaya gönderilen tüm verilerin dosyanın sonuna eklenmesini sağlar.
✔ Dosyaya yapılan her yazma işleminde, dosya konum göstergesi dosyanın sonunu gösterecek şekilde
ayarlanır
ios::ate ✔ Dosya açılışında, dosya konum göstergesini dosya sonuna ayarlar.
✔ Dosya konum göstergesi farklı bir konuma ayarlanabilir
ios::binary Dosyanın ikili modda açılmasını sağlar
ios::in Dosyayı veri okuma amacıyla açar
ios::out Dosyayı veri yazma amacıyla açar
ios::trunc ✔ Önceden var olan aynı isme sahip bir dosya içeriğinin tamamen silinmesini ve dosya uzunluğunun sıfır
değerine getirilmesini sağlar
✔ dosya açılırken ofstream parametresi kullanılırsa, aynı isme sahip bir dosya varsa, otomatik olarak içeriği
silinir
STANDARD TEMPLATE LIBRARY
C++ dilinde standartlaştırılmış, veri yapıları ve algoritmalar içeren bir kütüphanedir. STL, programcılara genellikle tekerleği yeniden icat etmeden çeşitli veri yapıları
ve algoritmalar kullanarak kodlarını daha verimli ve etkili bir şekilde yazmalarına olanak tanır
STL, üç ana bileşenden oluşur:
1. Kapsayıcılar (Containers):

✔ Vektör (vector): Dinamik boyutlu diziler.


✔ Dizi (array): Sabit boyutlu diziler.
✔ Liste (list): Çift yönlü bağlantılı listeler.
✔ İleri liste (forward_list): Tek yönlü bağlantılı listeler.
✔ Kuyruk (queue): FIFO (First-In-First-Out) yapısı.
✔ Yığın (stack): LIFO (Last-In-First-Out) yapısı.
✔ Çift uçlu kuyruk (deque): Dinamik boyutlu çift uçlu diziler.
✔ Küme (set): Sırasız, benzersiz elemanlar kümesi.
✔ Çoklu küme (multiset): Sırasız, tekrar eden elemanlar kümesi.
✔ Harita (map): Anahtar-değer çiftlerinden oluşan sıralı kapsayıcı.
✔ Çoklu harita (multimap): Anahtar-değer çiftlerinden oluşan sıralı kapsayıcı, bir anahtara birden fazla değer atanabilir.
✔ Kullanıcı tanımlı hash tabanlı veri yapıları (unordered_set, unordered_map): Hash tabanlı veri yapıları.
STANDARD TEMPLATE LIBRARY
2. Algoritmalar (Algorithms):

STL, sıralama (sort), arama (search), birleştirme (merge), dönüşüm (transform) gibi yaygın algoritmaları içerir. Bu algoritmalar, kapsayıcılar üzerinde çalışarak veri
manipülasyonunu kolaylaştırır.

3. İteratörler (Iterators)

İteratörler, kapsayıcılar üzerinde dolaşmayı sağlayan nesnelerdir. İşaretçi (pointer) benzeri bir yapıya sahiptirler.
VECTORS
Capacity
size() Returns the number of elements in the vector
max_size() Returns the maximum number of elements that the vector can hold
capacity Returns the size of the storage space currently allocated to the vector expressed as
number of elements
resize(n) Resizes the container so that it contains ‘n’ elements.
empty() Returns whether the container is empty
shrink_to_fit() Reduces the capacity of the container to fit its size and destroys all elements beyond the
capacity
reserve() Requests that the vector capacity be at least enough to contain n elements
VECTORS
Element Access

reference operator [n] Returns a reference to the element at position ‘n’ in the vector
at(n) Returns a reference to the element at position ‘n’ in the vector
front() Returns a reference to the first element in the vector
back() Returns a reference to the last element in the vector
data() Returns a direct pointer to the memory array used internally by the vector to
store its owned elements
VECTORS
Modifiers

assign() It assigns new value to the vector elements by replacing old ones
push_back() It push the elements into a vector from the back
pop_back() It is used to pop or remove elements from a vector from the back
insert() It inserts new elements before the element at the specified position
erase() It is used to remove elements from a container from the specified position or range
swap() It is used to swap the contents of one vector with another vector of same type. Sizes may differ.
clear() It is used to remove all the elements of the vector container
emplace() It extends the container by inserting new element at position
emplace_back() It is used to insert a new element into the vector container, the new element is added to the end of the
vector
LISTS
front Returns the value of the first element in the list
back Returns the value of the last element in the list.
push_front Adds a new element ‘n’ at the beginning of the list.
push_back Adds a new element ‘n’ at the end of the list.
pop_front Removes the first element of the list, and reduces the size of the list by 1
pop_back Removes the last element of the list, and reduces the size of the list by 1
insert Inserts new elements in the list before the element at a specified position
size Returns the number of elements in the list.
empty Returns whether the list is empty(1) or not(0).
erase Removes a single element or a range of elements from the list
remove Removes all the elements from the list, which are equal to a given element
assign Assigns new elements to the list by replacing current elements and resizing the list
reverse Reverses the list
sort Sorts the list in increasing order.
THANK YOU
Prepared by Fehmi Uyar

You might also like