I'm somewhat new to C++ I decided to work on a small project and I'm currently trying to set up something to make an array, put 5 objects into it and then increase its size and put more objects into it; however, I've run into an issue where I cannot figure out how to put data into the array
This is what I've got so far:
#include <iostream>
#include "Token.h"
int main()
{
Token* ts = new Token[5]; //create the initial array
ts[0] = new Token(TT_PLUS, "+"); //add the item
int size = sizeof(ts) / sizeof(Token); //get the new size
size_t newSize = size * 2; // double it
Token* newArr = new Token[newSize]; //create new array
memcpy(newArr, ts, size * sizeof(Token)); //copy data
size = newSize; //The array resizing is code I found, so I'm not sure why this is here...
delete[] ts; //delete old array data
ts = newArr; // array is now updated?
std::cout << ts[0].type << std::endl; trying to get the type of Token 0
}
This is my error(s):
Severity Code Description Project File Line Suppression State
Error (active) E0349 no operator "=" matches these operands ATestProgrammingLang C:\Users\usr\source\repos\ATestProgrammingLang\ATestProgrammingLang.cpp 10
Severity Code Description Project File Line Suppression State
Error C2679 binary '=': no operator found which takes a right-hand operand of type 'Token *' (or there is no acceptable conversion) ATestProgrammingLang C:\Users\usr\source\repos\ATestProgrammingLang\ATestProgrammingLang.cpp 10
Let me know if I need to give you more information.