42_rainfall/level9/source.cpp
2025-05-05 18:00:54 +02:00

45 lines
496 B
C++

#include <cstring>
#include <stdlib.h>
class N
{
public:
char annotation[100];
int nb;
N(int Nb)
{
nb = Nb;
}
void setAnnotation(char *str)
{
memcpy(annotation, str, strlen(str));
}
int operator+(N const &e)
{
return nb + e.nb;
}
int operator-(N const &e)
{
return nb - e.nb;
}
};
int main(int ac, char **av)
{
if (ac <= 1)
exit(1);
N *a = new N(5);
N *b = new N(6);
N *a_ptr = a;
N *b_ptr = b;
a_ptr->setAnnotation(av[1]);
return *b_ptr + *a_ptr;
}