Answer the question
In order to leave comments, you need to log in
What's wrong with the Vector class?
When compiling, I get: Process finished with exit code 11
template <typename T>
class Vect
{
private:
T *pvector;
size_t size, capacity;
public:
Vect() : pvector(NULL), size(0), capacity(0) { }
~Vect() { delete[] pvector; }
inline void push_back(const T &elem)
{
capacity;
pvector[size] = elem;
++size;
}
inline void pop_back()
{
T result = pvector[size - 1];
--size;
}
inline bool empty() const
{
return size == 0;
}
//возврат последнего элемента
inline const T back() const
{
return pvector[size - 1] ;
}
};
class Stack
{
private:
Vect<T> elems;
...
int main()
{
setlocale(LC_ALL,"ru");
Stack<int> is;
is.push(7);
is.push(9);
cout<<is.top()<<'\n';
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question