I started using C++ after learning Python, so I'm very very new to this. I'm writing a program and have 2 files in the project. I have my list.h class and my program. The list.h class, despite the fact that its a given class and should work, is ridled with errors. I won't post all the errors because its just too much but maybe if I show you guys the first error and help me fix it, I can keep working on the rest little by little so I can learn how to use this language from efficiently.
The code is:
// List.h
#ifndef _LIST_H_
#define _LIST_H_
#include <cstdlib>
class List {
public:
List(size_t capacity=10); // constructor - allocates dynamic array
List(const List &a); // copy constructor
~List(); // destructor
int& operator[](size_t pos); // bracket operator
List& operator=(const List &a); // assignment operator
List& operator+=(const List &a); // += operator
void append(int item);
size_t size() const { return size_; }
private:
void copy(const List &a);
void resize(size_t new_size); // allocate new larger array
int *data_; // dynamic array
size_t size_; // size of dynamic array
size_t capacity_; // capacity of dynamic array
};
inline int& List::operator[](size_t pos)
{
return data_[pos];
}
#endif // _LIST_H_
The first error is, "Unresolved inclusion: <cstdlib>". What should I do?