Thread: arrays

  1. #1


    I wrote a program to do the following:
    Write a destructor to return the dynamic memory used by the list to the heap.
    Write a function which returns the number of items in the list.
    Write a function which returns true if the list is full.
    Write a function to add one item to the list. The argument of the function contains the item to be added.
    Write a function to remove all of the items from the list.
    Write a function to print the contents of the list to a report.
    write a function to display the contents of the list to the display.
    i woul like to write a small program in main to test the array list.

    using namespace std;

    int main()

    List a;

    return 0;

    #include <iostream>

    List::List(int max)
    int current_length=0;
    typedef int*item;

    item a;
    a = new int[max];
    if ( a==NULL)
    cout<< "Error : Insufficient memory.\n";


    int List::length ()



    void List::add (int new_item)
    cout<<"Enter a new item to the list: "<<endl;

    cout<<"Error:adding to a full list."<<endl;


    int List::full()

    void List::erase ()


    delete[] a;

    I get the following error messages:

    error C2512: 'List' : no appropriate default constructor available
    Error executing cl.exe.(in main.cpp)

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    a default constructor is a constructor put there when none other is availiabe. it's to maintain backwards compatability with C structs. when you provide any constructor, C++ won't do this for you.
    so, either you:
    1) called a constructor but forgot to put arguements in
    2) assumed wrongly that there was a default constructor

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function to read in two arrays
    By ssmokincamaro in forum C Programming
    Replies: 7
    Last Post: 11-12-2008, 07:59 AM
  2. pointers & arrays and realloc!
    By zesty in forum C Programming
    Replies: 14
    Last Post: 01-19-2008, 04:24 PM
  3. Replies: 16
    Last Post: 01-01-2008, 04:07 PM
  4. Need Help With 3 Parallel Arrays Selction Sort
    By slickwilly440 in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2005, 10:47 PM
  5. Crazy memory problem with arrays
    By fusikon in forum C++ Programming
    Replies: 9
    Last Post: 01-15-2003, 09:24 PM