Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started