CPP07 1.0
読み取り中…
検索中…
一致する文字列を見つけられません
main.cpp
[詳解]
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* main.cpp :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: kamitsui <kamitsui@student.42tokyo.jp> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2025/08/07 20:50:48 by kamitsui #+# #+# */
9/* Updated: 2025/08/07 21:08:19 by kamitsui ### ########.fr */
10/* */
11/* ************************************************************************** */
12
18#include "whatever.hpp"
19#include <string>
20
29int main(void) {
30 int a = 2;
31 int b = 3;
32
33 std::cout << "Before swap : a = " << a << ", b = " << b << std::endl;
34 // use :: for function of global name space
35 ::swap(a, b);
36 std::cout << "After swap : a = " << a << ", b = " << b << std::endl;
37 std::cout << "min(a, b) = " << ::min(a, b) << std::endl;
38 std::cout << "max(a, b) = " << ::max(a, b) << std::endl;
39
40 std::string c = "chaine1";
41 std::string d = "chaine2";
42
43 std::cout << "Before swap : c = " << c << ", d = " << d << std::endl;
44 ::swap(c, d);
45 std::cout << "After swap : c = " << c << ", d = " << d << std::endl;
46 std::cout << "min(c, d) = " << ::min(c, d) << std::endl;
47 std::cout << "max(c, d) = " << ::max(c, d) << std::endl;
48
49 return 0;
50}
T endl(T... args)
int main(void)
The main entry point of the program.
Definition main.cpp:29
Contains template functions for basic operations like swap, min, and max.
T const & min(T const &a, T const &b)
Returns the smaller of two values. If the values are equal, it returns the second value.
Definition whatever.hpp:43
void swap(T &a, T &b)
Swaps the values of two variables.
Definition whatever.hpp:29
T const & max(T const &a, T const &b)
Returns the greater of two values. If the values are equal, it returns the second value.
Definition whatever.hpp:53