so i have written that code

/////////////////////////////////////////////////// template <typename T> inline void Push(T value) { // If the stack if full then dont add more if(m_uiArgs >= MAX_ARGS_VALUES) return; // Save the argument into the virtual stack *(T *)(m_ucValue + m_uiArgs * 4) = value; // Increase the arguments count m_uiArgs++; } /////////////////////////////////////////////////// template <typename T> inline T Pop() { // Decrease the arguments count m_uiArgs--; // Return the value return *(T *)(m_ucValue + m_uiArgs * 4); } private: unsigned int m_uiArgs; unsigned char m_ucValue[MAX_ARGS_VALUES * 4];

now this code normally saves values into the "m_ucValues" array when using the push function, then getting them when using the Pop, but what heppens is after pushing values, it only pops the last pushed value

Example:

Push(1500); // Integer Push("test string"); // String Push("test 2"); printf("%s - %s - %d", Pop<char *>(), Pop<char *>(), Pop<int>());

Output: test 2, test 2, 5465465456(cannot convert the string to integer)

im not sure if the last pushed value overwrites the previous ones, or the Pop function is bugged

any help will be greatly appreciated

Thanks