Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you please review my syntax? Im not sure if I wrote my if statement correctly and I'm confused about how to construct my for

Can you please review my syntax?

Im not sure if I wrote my if statement correctly and I'm confused about how to construct my for loop

MyVector(size_t capacity = MyVector::DEFAULT_CAPACITY) {

capacity_ = capacity;

size_ = 0;

// make a line for if the capacity is less than MINIMUM_CAPACITY then set it to MINIMUM_CAPACITY then make an empty array with that capacity

if (capacity_ < MINIMUM_CAPACITY) {

capacity_ = MINIMUM_CAPACITY;

}

data_ = new T[capacity_];

}

MyVector(const MyVector &other)

{

capacity_ = other.capacity_;

size_ = other.size_;

data_ = new T[capacity_];

data_[i] = other.data_[i];

// make a for loop based on the other vector's size and copy the elements in the other vector's array one by one

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions

Question

Define outplacement and severance pay.

Answered: 1 week ago