Skip to content

Commit 9f00a19

Browse files
committed
first commit
0 parents  commit 9f00a19

File tree

4 files changed

+118
-0
lines changed

4 files changed

+118
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.DS_STOre
2+
.vscode
3+
*.d
4+
*.o
5+

ex00/Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# **************************************************************************** #
2+
# #
3+
# ::: :::::::: #
4+
# Makefile :+: :+: :+: #
5+
# +:+ +:+ +:+ #
6+
# By: romainjobert <[email protected] +#+ +:+ +#+ #
7+
# +#+#+#+#+#+ +#+ #
8+
# Created: 2024/02/19 22:16:54 by romainjober #+# #+# #
9+
# Updated: 2024/02/19 22:17:16 by romainjober ### ########.fr #
10+
# #
11+
# **************************************************************************** #
12+
13+
CC = c++
14+
NAME = ex00
15+
FLAGS = -Wall -Wextra -Werror -std=c++98 -pedantic -MMD -I ./
16+
HEADER = whatever.hpp
17+
SRC = main.cpp
18+
OBJS = $(SRC:.cpp=.o)
19+
DEPS = $(SRC:.cpp=.d)
20+
RM = rm -rf
21+
22+
all: $(NAME)
23+
24+
-include $(DEPS)
25+
$(NAME): $(OBJS)
26+
$(CC) $(FLAGS) $(OBJS) -o $(NAME)
27+
28+
%.o: %.cpp Makefile $(HEADER )
29+
$(CC) $(FLAGS) -c $< -o $@
30+
31+
clean:
32+
$(RM) $(OBJS) $(DEPS)
33+
34+
fclean: clean
35+
$(RM) $(NAME)
36+
37+
re: fclean all
38+
39+
.PHONY: clean fclean all re

ex00/main.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* main.cpp :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: romainjobert <[email protected] +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2024/02/19 22:09:35 by romainjober #+# #+# */
9+
/* Updated: 2024/02/19 22:19:15 by romainjober ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
13+
#include "whatever.hpp"
14+
15+
int main(void)
16+
{
17+
int a = 2;
18+
int b = 3;
19+
::swap( a, b );
20+
std::cout << "a = " << a << ", b = " << b << std::endl;
21+
std::cout << "min( a, b ) = " << ::min( a, b ) << std::endl;
22+
std::cout << "max( a, b ) = " << ::max( a, b ) << std::endl;
23+
std::string c = "chaine1";
24+
std::string d = "chaine2";
25+
::swap(c, d);
26+
std::cout << "c = " << c << ", d = " << d << std::endl;
27+
std::cout << "min( c, d ) = " << ::min( c, d ) << std::endl;
28+
std::cout << "max( c, d ) = " << ::max( c, d ) << std::endl;
29+
return 0;
30+
}

ex00/whatever.hpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* whatever.hpp :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: romainjobert <[email protected] +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2024/02/19 22:11:23 by romainjober #+# #+# */
9+
/* Updated: 2024/02/19 22:32:37 by romainjober ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
13+
#ifndef WHATEVER_HPP
14+
# define WHATEVER_HPP
15+
16+
# include <iostream>
17+
# include <string>
18+
19+
template <typename T>
20+
void swap(T& a, T& b)
21+
{
22+
T temp = b;
23+
b = a;
24+
a = temp;
25+
}
26+
27+
template <typename T>
28+
T min(const T& a, const T& b)
29+
{
30+
if (a < b)
31+
return (a);
32+
return (b);
33+
}
34+
35+
template <typename T>
36+
T max(const T& a, const T& b)
37+
{
38+
if (a > b)
39+
return (a);
40+
return (b);
41+
}
42+
43+
#endif
44+

0 commit comments

Comments
 (0)