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 {

  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_; }

  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?

4 Years
Discussion Span
Last Post by Ancient Dragon

Did you check that the compiler was C++? It may be defaulting to C. I know NetBeans - C\C++ plugin will do this sometines.

Edited by gerard4143


I must've went over it a hundred times. The only thing I notice that might be the problem is my library. Maybe that's why I'm having problems with inclusion. The other errors are coming from the types so now I'm just trying to figure out how to get the program to include the library...to no avail though.


Are you sure that your IDE has <cstdlib> library?

Edited by Neuman


I deleted eclipse and download it again, all seems to work as it should but for some reason the program is filled with errors that I'm not sure how to fix.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.