c++ memories
c++ memories
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
C++ NEDEN C+
NEDİR? +?
C++ ile Neler Yapılır?
01 Video Oyunları
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
01 If 02 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
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
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):
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