预定/报价
C++代写 | CS11440 Lab 6 – Class Templates
阿叶2024-05-15 17:53:29

留学生作业代写do not hesitate to contact me!
WeChat:lovexc60


Templates in C++ is not a difficult idea. This lab is not intended to help you understand the details of how templates work. It is only intented to give students an opportunity to start developing code using templated classes.

Everyone in the class has had to come to grips with the usage of variables in general. With templates, you can think of the type of the variable being a variable itself. The programmer is just saying that when you want to instantiate an instance of this class you will need to tell the compiler which variable type the class needs to use. After understanding that, templates just become a syntactical change.

Developing a templated class is not difficult either. I think the syntax is the most difficult aspect. It’s just pure ugly. So, I suggest that you approach the MyArray class as if it was the I nt Array class. Yes, I’m suggesting that you write pushBack, popBack, getSize, isEmpty, operator[], and toString as if you were writing the IntArray class we developed in the Big 4 lab. After completing that implementation and testing for correctness, go back and change all necessary instances of int to the template variable.

Here’s the MyArray class written as Mylnt from the Big 4 lab.

// You won * t be able to inherit from ContainerIfc at this point which means you may

// have to test locally to begin with.

class MyArray (

int *data;

int capacity, size;

// You will need to write all function defintions outside of the class defintion MyArray();