I'm trying to make a basic class right now which can do some functions that std::vector can do. I'm having some problem with the logic of it, I noted in the code below the questions I had. I mostly want to know the first one/few... I am stuck on the constructor/dynamic allocation part so I can't really work on the others yet.
/*This Vector Will only implement move semantics not copying
class Vec
{
public:
/**
* new Vec contains startsize elements all set to 0. dynamically allocate memory to hold ints and pass to priv constructor.
* each set to zero.
*/
static Vec Create(size_t startsize);//This is the one I'm the most confused about. I think I need to point to the private field but I don't really know what I'm doing with it. Should I be pointing the vec or the startsize? Should it be like Vec*=..?
Vec(IntVector&&);
Vec operator= (IntVector&&);
// Num of Values
size_t size() const;//Can I just use return size from my constructor? Usually my constructors are in private field so this one is different then normal for me. Do I need another private field?
// Num of Elements without resize
size_t capacity() const;//Similar to one above, I assume I just return a basic thing like return len. Not sure if this works with the private constructor, before I'd use something like "int len" in private for example.
//Pointer to an int
typedefint* iterator;//Which int am I pointing to?
iterator begin();//Just the first value of the array?
iterator end();//Last value of array? How can I get this?
/**Push back function,
If array is too small, copy into new bigger array.
*/
Vec& push_back(int value);
/*Same as Push back function
*/
Vec& operator<< (int value);
private:
Vec(int *values, size_t len);
};