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

48 lines
816 B
C++
Raw Permalink Normal View History

#include <iostream>
#ifndef DIALER_HH
#define DIALER_HH
#include "Button.hh"
#define DEFAULT_NUMBER_BUTTONS 12
class Dialer {
public:
2019-12-17 15:05:27 +01:00
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];
}
2019-12-17 15:05:27 +01:00
}
~Dialer() {
std::cout << "Dialer Destructor " << this << std::endl ;
delete[] buttons ;
}
private:
2019-12-17 15:05:27 +01:00
void init()
{
this->init( DEFAULT_NUMBER_BUTTONS );
}
void init( int num_buttons )
{
buttons_size = num_buttons;
buttons = new Button[buttons_size];
2019-12-17 15:05:27 +01:00
}
Button* buttons ;
int buttons_size;
} ;
#endif