main.cpp
 1  /* ************************************************************************** */
 2  /*                                                                            */
 3  /*                                                        :::      ::::::::   */
 4  /*   main.cpp                                           :+:      :+:    :+:   */
 5  /*                                                    +:+ +:+         +:+     */
 6  /*   By: gychoi <gychoi@student.42seoul.kr>         +#+  +:+       +#+        */
 7  /*                                                +#+#+#+#+#+   +#+           */
 8  /*   Created: 2023/07/25 21:17:23 by gychoi            #+#    #+#             */
 9  /*   Updated: 2023/07/25 22:33:06 by gychoi           ###   ########.fr       */
10  /*                                                                            */
11  /* ************************************************************************** */
12  
13  #include "HumanA.hpp"
14  #include "HumanB.hpp"
15  
16  #ifdef LEAKS_CHECK
17  #include <cstdlib>
18  void	check_leaks(void)
19  {
20  	system("leaks --list -- violence");
21  }
22  #define ATEXIT_CHECK() atexit(check_leaks)
23  #else
24  #define ATEXIT_CHECK()
25  #endif
26  
27  int	main()
28  {
29  	ATEXIT_CHECK();
30  	{
31  		Weapon	club = Weapon("crude spiked club");
32  
33  		HumanA	bob("Bob", club);
34  		bob.attack();
35  		club.setType("some other type of club");
36  		bob.attack();
37  	}
38  	{
39  		Weapon	club = Weapon("crude spiked club");
40  
41  		HumanB	jim("Jim");
42  		jim.setWeapon(club);
43  		jim.attack();
44  		club.setType("some other type of club");
45  		jim.attack();
46  	}
47  
48  	return 0;
49  }