#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    19
    Rep Power
    0

    Question C++ constructor problem, have no idea really


    hi
    i have a little problem

    i define
    a class ZList in a file called List.h

    class ZList{
    int capacity;
    int count;
    void **list;
    public:
    ZList(int Capacity = 20 );
    ~ZList();
    int Add(void * item);
    void Clear();
    bool Delete(int index);
    int GetCount();
    int Indexof(void * item);
    int Insert(void * item , int index);
    void * ItemAt(int index);
    }

    and then when i want to write the constructor :

    #include <stdlib>
    #pragma hdrstop

    #include "List.h"
    //----------------------------------------------------
    ZList::ZList(int Capacity )
    {
    capacity=Capacity;
    count =0;
    list = new (void *[capacity]);
    for(int i = 0 ; i <count ; i++){
    list[i]=NULL;
    }
    }

    i receive two errors


    [C++ Error] List.cpp(7): E2111 Type 'ZList' may not be defined here
    [C++ Error] List.cpp(7): E2136 Constructor cannot have a return type specification


    can u tell me my mistake
    because i have really no idea
  2. #2
  3. No Profile Picture
    status unknown
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    262
    Rep Power
    11

    Re: C++ constructor problem, have no idea really


    Originally posted by murph
    class ZList{
    int capacity;
    ......
    void * ItemAt(int index);
    }

    Just a thought - do you have a semi-colon at that end of the class declaration in the original code?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    19
    Rep Power
    0

    Talking :)thanks


    thank u :)
    i have not seen that

IMN logo majestic logo threadwatch logo seochat tools logo