Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Тестовые примеры / ch2 / menu
.C // source file name: menu.C
#include <string.h>
#include "menu.h"
int menu::num_fields = 0;
// constructor with an argument
menu::menu ( const char* str )
{
title = new char[strlen(str)+1];
strcpy (title, str );
num_fields = 0;
}
// constructor with no argument
menu::menu()
{
title = 0;
num_fields = 0;
}
// a destructor
menu::~menu()
{
delete title;
}
// a non-static member function
void menu::incr_field ( int siz )
{
num_fields += siz;
}
// a static member function
int menu::fields()
{
return num_fields;
}
// another non-static member function.
char* menu::name()
{
return title;
}
#include <string.h>
#include "menu.h"
int menu::num_fields = 0;
// constructor with an argument
menu::menu ( const char* str )
{
title = new char[strlen(str)+1];
strcpy (title, str );
num_fields = 0;
}
// constructor with no argument
menu::menu()
{
title = 0;
num_fields = 0;
}
// a destructor
menu::~menu()
{
delete title;
}
// a non-static member function
void menu::incr_field ( int siz )
{
num_fields += siz;
}
// a static member function
int menu::fields()
{
return num_fields;
}
// another non-static member function.
char* menu::name()
{
return title;
}
Соседние файлы в папке ch2