Skip to content

Commit 0b1ca1d

Browse files
committed
update cpp08, add cpp09, update README.md for better description
1 parent da0aa4e commit 0b1ca1d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+3156
-209
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vscode

README.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# CPP-Exercises
22

3-
Target: OOP Programming
3+
Target: C++ OOP Programming
44

5-
This Project consists of many subprojects, whose goal is to establish and instantly deepen your basis in C++ Object-Oriented programming concepts.
6-
The Subprojects aims to develop my skillset in the following areas:
7-
CPP00: Namespaces, classes, member functions, stdio streams, initialization lists, static/const, and other basic stuff. Introductory Subproject.
5+
This Project consists of many subprojects, whose goal is to establish and deepen my knowledge in C++ Object-Oriented Programming Concepts.
86

9-
CPP01: C++ style memory allocation, pointers to members, references. Introductory 2.0.
7+
The Subprojects aim to develop my skillset in the following areas:
108

11-
CPP02: AD-hoc polymorphism, operator overloading and Orthodox Canonical class form (Constr/Destr/Copy/Overl. Assignment Operator)
9+
CPP00: Namespaces, classes, member functions, stdio streams, initialization lists, static/const.
10+
11+
CPP01: C++ style memory allocation, pointers to members, references.
12+
13+
CPP02: AD-Hoc polymorphism, operator overloading and Orthodox Canonical class form (Constr/Destr/Copy/Overl. Assignment Operator)
1214

1315
CPP03: Inheritance
1416

@@ -20,4 +22,13 @@ CPP06: C++ style Casts
2022

2123
CPP07: C++ Templates
2224

23-
CPP08: Templated Containers, Iterators, Algorithms <UNDER CONSTRUCTION>
25+
CPP08: Templated containers, iterators, algorithms
26+
27+
CPP09: STL (Standard Template Library), Use Cases of different Custom Data Structures
28+
29+
What's worth looking at the most to my opinion are: CPP08, CPP09, CPP03
30+
31+
How to check the projects:
32+
1. Each CPPXX is an individual projects of the 42Curriculum
33+
2. Inside each CPPXX folder, you find Y exercises and the description of the exercises (subject.pdf)
34+
3. Ideal way to check the exercises is to go into the individual exercise directory, execute "make", run the program while reading the requirements in the subject.pdf
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

cpp00/subject.pdf

1.57 MB
Binary file not shown.

cpp01/subject.pdf

1.6 MB
Binary file not shown.

cpp02/subject.pdf

1.65 MB
Binary file not shown.

cpp03/subject.pdf

1.54 MB
Binary file not shown.

cpp04/subject.pdf

1.61 MB
Binary file not shown.

cpp05/subject.pdf

1.61 MB
Binary file not shown.

cpp06/subject.pdf

1.56 MB
Binary file not shown.

cpp07/subject.pdf

1.58 MB
Binary file not shown.

cpp08/ex00/Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,21 @@
55
# +:+ +:+ +:+ #
66
# By: agunczer <agunczer@student.42.fr> +#+ +:+ +#+ #
77
# +#+#+#+#+#+ +#+ #
8-
# Created: 2022/04/01 18:10:56 by agunczer #+# #+# #
9-
# Updated: 2022/04/13 09:30:45 by agunczer ### ########.fr #
8+
# Created: 2022/03/26 16:49:39 by agunczer #+# #+# #
9+
# Updated: 2024/02/05 11:34:01 by agunczer ### ########.fr #
1010
# #
1111
# **************************************************************************** #
1212

13-
NAME = serialize
13+
NAME = main
1414

15-
CC = clang++
15+
CC = g++
1616

1717
CFLAGS = -Wall -Wextra -Werror -std=c++98
1818

1919
SRC = main.cpp
2020

2121
OBJ = $(SRC:.cpp=.o)
2222

23-
HEAD = easyfind.hpp
2423
all : $(NAME)
2524

2625
$(NAME) : $(SRC) $(HEAD)

cpp08/ex00/easyfind.hpp

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,20 @@
55
/* +:+ +:+ +:+ */
66
/* By: agunczer <agunczer@student.42.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
8-
/* Created: 2022/04/11 17:15:13 by agunczer #+# #+# */
9-
/* Updated: 2022/04/13 09:49:54 by agunczer ### ########.fr */
8+
/* Created: 2024/02/05 11:34:12 by agunczer #+# #+# */
9+
/* Updated: 2024/02/05 11:42:23 by agunczer ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

13+
#ifndef EASYFIND_HPP
14+
#define EASYFIND_HPP
15+
1316
#include <iostream>
17+
#include <algorithm>
1418
#include <vector>
1519
#include <list>
16-
#include <array>
17-
#include <algorithm>
18-
#include <string>
20+
#include <deque>
21+
22+
template <class T> typename T::iterator easyFind(T*, int);
1923

20-
template <typename T>
21-
typename T::iterator easyfind(T cont, const int& toFind) {
22-
typename T::iterator it = std::find(cont.begin(), cont.end(), toFind);
23-
24-
if (it == cont.end())
25-
{
26-
std::cout << "not found" << std::endl;
27-
return it;
28-
}
29-
else
30-
return it;
31-
}
24+
#endif

cpp08/ex00/easyfind.tpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* easyfind.tpp :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: agunczer <agunczer@student.42.fr> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2024/02/05 11:34:08 by agunczer #+# #+# */
9+
/* Updated: 2024/02/05 11:34:08 by agunczer ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
13+
#include "easyfind.hpp"
14+
15+
template <class T> typename T::iterator easyFind(T *sourceArray, int toFind) {
16+
typename T::iterator start = sourceArray->begin();
17+
typename T::iterator end = sourceArray->end();
18+
19+
typename T::iterator found = std::find(start, end, toFind);
20+
if (*found == toFind)
21+
return found;
22+
else
23+
return found;
24+
}

cpp08/ex00/main.cpp

Lines changed: 13 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -5,76 +5,24 @@
55
/* +:+ +:+ +:+ */
66
/* By: agunczer <agunczer@student.42.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
8-
/* Created: 2022/04/11 17:15:15 by agunczer #+# #+# */
9-
/* Updated: 2022/04/13 09:40:08 by agunczer ### ########.fr */
8+
/* Created: 2024/02/05 11:34:04 by agunczer #+# #+# */
9+
/* Updated: 2024/02/05 12:23:53 by agunczer ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

13-
#include "easyfind.hpp"
13+
#include "easyfind.tpp"
1414

15-
int main(void) {
16-
{
17-
std::vector<int> vect;
18-
vect.push_back(10);
19-
vect.push_back(20);
20-
vect.push_back(30);
21-
22-
std::vector<int>::iterator it = easyfind(vect, 9);
23-
std::vector<int>::iterator it2 = easyfind(vect, 30);
24-
25-
std::cout << &(*it) << std::endl;
26-
std::cout << &(*it2) << std::endl;
27-
28-
// return 0;
29-
}
15+
int main() {
16+
std::list<int> array;
17+
array.push_back(6);
18+
array.push_back(2);
19+
array.push_back(3);
3020

31-
{
32-
std::list<int> list;
21+
std::list<int>::iterator ptr = easyFind(&array, 12);
3322

34-
list.push_back(40);
35-
list.push_back(50);
36-
list.push_back(60);
37-
38-
std::list<int>::iterator it = easyfind(list, 62);
39-
std::list<int>::iterator it2 = easyfind(list, 60);
40-
41-
std::cout << &(*it) << std::endl;
42-
std::cout << &(*it2) << std::endl;
43-
44-
// return 0;
45-
}
23+
std::cout << "Not Found: " << std::endl << " Value we are looking for: 12" << std::endl << " Value returned: " << *ptr << std::endl;
4624

47-
{
48-
std::array<int, 3> array = {1, 2 ,3};
49-
50-
std::array<int, 3>::iterator it1 = easyfind(array, 0);
51-
std::array<int, 3>::iterator it2 = easyfind(array, 1);
52-
std::array<int, 3>::iterator it3 = easyfind(array, 2);
53-
std::array<int, 3>::iterator it4 = easyfind(array, 3);
54-
std::array<int, 3>::iterator it5 = easyfind(array, 4);
55-
56-
std::cout << "address of it1 at: " << &(*it1) << std::endl;
57-
std::cout << "address of it2 at: " << &(*it2) << std::endl;
58-
std::cout << "address of it3 at: " << &(*it3) << std::endl;
59-
std::cout << "address of it4 at: " << &(*it4) << std::endl;
60-
std::cout << "address of it5 at: " << &(*it5) << std::endl;
61-
62-
// return 0;
63-
}
25+
ptr = easyFind(&array, 6);
6426

65-
// {
66-
// std::vector<int[3]> vect;
67-
// int k[3] = {1, 2, 3};
68-
// vect.push_back(k);
69-
// vect.push_back(k);
70-
// vect.push_back(k);
71-
72-
// std::vector<int[3]>::iterator it = easyfind(vect, 1);
73-
// std::vector<int[3]>::iterator it2 = easyfind(vect, 30);
74-
75-
// std::cout << &(*it) << std::endl;
76-
// std::cout << &(*it2) << std::endl;
77-
78-
// // return 0;
79-
// }
80-
}
27+
std::cout << "Found: " << std::endl << " Value we are looking for: 6" << std::endl << " Value returned: " << *ptr << std::endl;
28+
}

cpp08/ex01/Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@
55
# +:+ +:+ +:+ #
66
# By: agunczer <agunczer@student.42.fr> +#+ +:+ +#+ #
77
# +#+#+#+#+#+ +#+ #
8-
# Created: 2022/04/01 18:10:56 by agunczer #+# #+# #
9-
# Updated: 2022/04/13 15:37:01 by agunczer ### ########.fr #
8+
# Created: 2022/03/26 16:49:39 by agunczer #+# #+# #
9+
# Updated: 2024/02/05 11:33:58 by agunczer ### ########.fr #
1010
# #
1111
# **************************************************************************** #
1212

13-
NAME = serialize
13+
NAME = main
1414

15-
CC = clang++
15+
CC = g++
1616

1717
CFLAGS = -Wall -Wextra -Werror -std=c++98
1818

1919
SRC = main.cpp Span.cpp
2020

2121
OBJ = $(SRC:.cpp=.o)
2222

23-
HEAD = Span.hpp
23+
# HEAD =
2424
all : $(NAME)
2525

2626
$(NAME) : $(SRC) $(HEAD)
@@ -36,4 +36,4 @@ fclean :
3636

3737
re :
3838
make fclean
39-
make $(NAME)
39+
make $(NAME)

0 commit comments

Comments
 (0)