информационная безопасность
без паники и всерьез
 подробно о проектеRambler's Top100
Страшный баг в WindowsSpanning Tree Protocol: недокументированное применениеСетевые кракеры и правда о деле Левина
BugTraq.Ru
Русский BugTraq
 Анализ криптографических сетевых... 
 Модель надежности двухузлового... 
 Специальные марковские модели надежности... 
 Бэкдор в xz/liblzma, предназначенный... 
 Три миллиона электронных замков... 
 Doom на газонокосилках 
главная обзор RSN блог библиотека закон бред форум dnet о проекте
bugtraq.ru / форум / beginners
Имя Пароль
ФОРУМ
если вы видите этот текст, отключите в настройках форума использование JavaScript
регистрация





Легенда:
  новое сообщение
  закрытая нитка
  новое сообщение
  в закрытой нитке
  старое сообщение
  • Напоминаю, что масса вопросов по функционированию форума снимается после прочтения его описания.
  • Новичкам также крайне полезно ознакомиться с данным документом.
Господа, будьте снисходительны, не бросайтесь сразу штрафовать за, как вам кажется, глупые вопросы - beginners на то и beginners.
Pomogite, pozhalujsta, s kontrolnoj po C++ 05.05.05 23:34  
Автор: yuka Статус: Незарегистрированный пользователь
<"чистая" ссылка>
Sovsem nedavno nachala izuchat C++. Dla togo, chtoby zakonchit semestr, mne neobhodimo napisat programmu. Ja sovsem zaputalas i na znaju nikogo, k komu mozhno obratitsja za pomoshju. Pomogite razobratsja, pozhalujsta.
Spasibo


Uslovie:

Create an Array class to hold an array of integers. An object of the Array class should be very much like a built-in C++ array, except that an Array object has some additional functionality that the built-in C++ array does not.

Listed below is a description of the functionality your Array object should possess.

Given the following declaration statements for 3 objects of the Array class,

int a[3] = {10, 20, 30}, b = {40, 50, 60, 70, 80};

Array myArray1, myArray2, myArray3;

the following member functions should be included:

A default constructor to initialize an Array object to an integer array of size 20, with all elements being initialized to zero.
A constructor of the type
myArray1 = Array(a, 3);

which initializes myArray1 to hold the values of the array, "a", which is 3 elements long.

If myArray2 was an Array object that held the values of the integer "b" array, then the member function
myArray2.add_begin(a, 3);

would have the values of the "a" array added to the beginning of it, so that it would now hold the following values

10, 20, 30, 40, 50, 60, 70, 80

in that order.

If myArray1 was an Array object that held the values of the integer "a" array, then the member function
myArray1.add_end(b, 5);

would have the values of the "b" array added to the end of it, so that it would now hold the following values

10, 20, 30, 40, 50, 60, 70, 80

in that order.

If myArray2 was an Array object that held the values of the integer "b" array, then the member function
myArray2.remove_begin(3);

would remove the first 3 values of the array so that it would now hold the following values

70, 80

in that order.

If myArray2 was an Array object that held the values of the integer "b" array, then the member function
myArray2.remove_end(3);

would remove the last 3 values of the array so that it would now hold the following values

40, 50

in that order.

The member function
myArray1.resize(200);

would resize the Array object to be 200 elements long. If the original size of the Array object was bigger, elements would be removed from the end of the array. If the original size of the Array object was smaller, then the appropriate number of zeros would be added to the end of the Array object.

If myArray1 was an Array object that held the values of the integer "a" array, and myArray2 was an Array object that held the values of the integer "b" array, then the addition operator and assignment operator should be overloaded as members of the class so that one could write:
myArray3 = myArray1 + myArray2;

The addition operator would concatenate the elements of myArray2 to the end of the elements in myArray1 so that myArray3 would hold the elements

10, 20, 30, 40, 50, 60, 70, 80

in that order.

Provide a copy constructor for the class.
Provide a destructor for the class.
Be sure to implement all arrays within the class as pointers which point to dynamically allocated arrays.
Whenever it is required to change the size of an Array object, be sure to do it by dynamically allocating a new array of the proper size, copying the appropriate values to the new array, and then unallocating the old array.
At a minimum, your class should include the following:
class Array

{

public:

/* Add all of the required member functions here. */

private:

int size;

int *array;

};
1




Rambler's Top100
Рейтинг@Mail.ru


  Copyright © 2001-2024 Dmitry Leonov   Page build time: 0 s   Design: Vadim Derkach