logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

Programming / Algorithms & Data Structures Define template<class T> class myVector from lecture completely, i.e. all members.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Since the deadline is approaching I would like help with the following assigment in C++ Programming.

 

Page 1from

2

Programming / Algorithms & Data Structures 2

Practical course 2

O. SKROCH

Carefully read the information and complete all tasks. However, do not make more

for the acceptances (testates). Place value on quality.

Task 1

Template class, container with variable number of elements

a) Define template<class T> class myVector from lecture completely,

i.e. all members. Hint:

myVector( )

explicit myVector( int, T = T{} )

myVector( const myVector& )

myVector& operator=( const myVector& )

~myVector( )

int size( ) const

int capacity( ) const

T& operator[]( int )

T& at( int ) // Access area checked const

T& operator[]( int ) const

const T& at( int ) const

void reserve( int )

void resize( int, T = T{} )

void push_back( const T& )

To do this, build on the corresponding source code developed during the lecture. Stick to

new and delete for the memory management of the encapsulated data field, do not

use allocators.

b) Experiment with the constructors (including the copy constructor), the assignment operator,

and the destructor until you understand what exactly happens. To do this, try out each of

the methods on at least three small examples that you come up with yourself. Have the

methods output some informative string so that you can see on the screen when they

take action. (If necessary, look again at the technical literature and the documents from

PAD1).

c) Test in a planned and systematic way with a sufficient amount of test cases carefully

predefined by you, log all test results.

Subscribe to DeepL Pro to translate larger documents.

Visit www.DeepL.com/pro for more information.

Page 2from

2

P/AD-2 practical course 2h_da - fb i - osk

Task 2

Template class, container with fixed number of elements

Develop a program to manage the parking spaces in a parking garage. Let there be only ten

parking spaces in total for the demonstration. The parking spaces are clearly numbered and can

be occupied and released again by people looking for a parking space. However, three of the

spaces are permanently reserved for long-term parkers, i.e. these spaces have an identifier

(which identifies the respective long-term parker by a name, such as "McFly" or

"DA-RS 123"). For those seeking parking, the permanent parking spaces are not available, only the

normal parking spaces.

With the program one should be able to occupy and release normal spaces, and also manage

the three long-term parking spaces (i.e. "book" and "cancel" them). Initially, all spaces are

free and no long-term parking names are assigned (the three long-term parking names can

then be e.g. "noname" or string{}).

If there are no normal spaces free, the program should not allow any more park seekers.

Also set myArray<T,N> from the lecture in the program.

Task 3

Template class, constructors, destructors

a) Define a class Tracer<T> for objects with integrated counter. Equip the template with a

counter called counter of type int, which is shared by all objects and which

manages the number of all Tracer<T> objects in your program (hint: static member

variable). The class should also have a member called value of type T.

The constructors (including the default and copy constructors) and the destructor of the class

should also output some informative string (so that you can see on the screen when they

are active).

b) Also use this class to determine how and where constructors and destructors perform their

tasks. That is, experiment with objects of type Tracer<T> , as local variables, global

constants, with newly created objects, etc. Also investigate copy operations with your

Tracer<T> objects, for this purpose define the assignment operation in addition to the copy

constructor from part a).

(5/5)
Attachments:

Expert's Answer

790 Times Downloaded

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

790 Times Downloaded

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Atharva PatilComputer science

1000 Answers

Hire Me
expert
Chrisantus MakokhaComputer science

821 Answers

Hire Me
expert
AyooluwaEducation

876 Answers

Hire Me
expert
RIZWANAMathematics

855 Answers

Hire Me

Get Free Quote!

291 Experts Online