#Dynamic vector class + template

23 messages · Page 1 of 1 (latest)

chrome flameBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

nocturne verge
#

if you're mimicing std::vector vector<int> v(5) should initialize it with 5 elements, so create a constructor that takes a std::size_t as argument

pastel quartz
#

what error are you getting?

nocturne verge
#

where? you have a constructor taking a vector and an int?

pastel quartz
nocturne verge
#

ah + more

#

probably linker errors

#

assuming he defined the functions in a .cpp file

pastel quartz
#
  • more?
nocturne verge
#

//+ more

rugged jolt
#

And notice that Vector<T>& is the same as simply Vector&

pastel quartz
#

Does that work in the first Vector<T> of the definition too?

bitter tiger
#

@brave chasm why are you passing vector as a argument in parameterized constructor?

chrome flameBOT
#

@brave chasm

Please Do Not Delete Posts!

Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.

rugged jolt
pastel quartz
#

Vector<T>::Vector(etc etc)

rugged jolt
#

It was meant more for parameters, Vector(const Vector<T>& rhs);

#

Well actually I am not sure that that would be considered a copy constructor at all even if T of rhs equals the current T

#

Vector(const Vector& rhs) clearly would

#

;compile -std=c++20


#include <type_traits>
#include <iostream>
template<class T>
struct Foo {
   Foo(const Foo<T>& other) = delete;
private:
   // Foo(const Foo& other) {}
};

int main(){
   std::cout << std::is_copy_constructible<Foo<int>>::value;
}
plucky zodiacBOT
#
Program Output
0