1
0
Fork 0
This repository has been archived on 2021-11-03. You can view files and clone it, but cannot push or open issues or pull requests.
uni-m.cds-adv-prog/ex4.1/Dialer.hh

47 lines
816 B
C++

#include <iostream>
#ifndef DIALER_HH
#define DIALER_HH
#include "Button.hh"
#define DEFAULT_NUMBER_BUTTONS 12
class Dialer {
public:
Dialer() {
std::cout << "Dialer Constructor " << this << std::endl ;
init();
}
Dialer(const Dialer& other) {
std::cout << "Dialer Copy Constructor " << this << std::endl ;
init(other.buttons_size);
// Copy the buttons
for ( int i = 0; i < other.buttons_size; i++ ) {
buttons[i] = other.buttons[i];
}
}
~Dialer() {
std::cout << "Dialer Destructor " << this << std::endl ;
delete[] buttons ;
}
private:
void init()
{
this->init( DEFAULT_NUMBER_BUTTONS );
}
void init( int num_buttons )
{
buttons_size = num_buttons;
buttons = new Button[buttons_size];
}
Button* buttons ;
int buttons_size;
} ;
#endif