From: "Joanna Baldacci" Newsgroups: comp.os.msdos.djgpp Subject: Re: newbie q: code and error messages. this is quite long. Date: Fri, 17 Dec 1999 09:53:05 -0000 Organization: UUNET WorldCom server (post doesn't reflect views of UUNET WorldCom Lines: 236 Message-ID: <83d19h$djc$1@lure.pipex.net> References: <83bjma$90h$1 AT lure DOT pipex DOT net> NNTP-Posting-Host: userbf69.uk.uudial.com X-Trace: lure.pipex.net 945424497 13932 62.188.142.90 (17 Dec 1999 09:54:57 GMT) X-Complaints-To: abuse AT uk DOT uu DOT net NNTP-Posting-Date: 17 Dec 1999 09:54:57 GMT X-Newsreader: Microsoft Outlook Express 4.72.2106.4 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com In response to mails and replies: thankyou for your interest in my woes. code and error messages are included. the errors are generated when I add 'char name[]' to the customer header in the protected section. sorry if this seems like loads but i'm not sure where the problem is coming from. Like I said, its fine without the 'name' declaration, When I said deleting all the files I just meant my code files, and replacing them. Sorry for not being more specific. Please don't laugh at my code. I'm fairly new to this and attempting a big project. All Im trying to do at the moment though is set up an array of customers who have names and numbers. How hard can this be? Obviously harder than i thought! thanks again joanna ************************************* Error messages: ************************************* In file included from Custs.cpp:4: Custs.h:20: field `array_of_customers' has incomplete type Custs.cpp:7: cannot declare member function `customer::customers::customers' wit hin `customer' Custs.cpp:12: cannot declare member function `customer::customers::getCustomer' within `customer' Custs.cpp:18: cannot declare member function `customer::customers::setCustomer' within `customer' Custs.cpp:24: cannot declare member function `customer::customers::customers' wi thin `customer' Custs.cpp:31: parse error at end of input Customer.cpp:11: `customer::customer()' has already been declared in `customer' Customer.cpp:17: `customer::~customer()' has already been declared in `customer' Customer.cpp:24: `customer::getnumber()' has already been declared in `customer' Customer.cpp:29: `customer::setnumber(int)' has already been declared in `custom er' Customer.cpp:35: `customer::display()' has already been declared in `customer' Customer.cpp:43: parse error at end of input In file included from Test.cpp:3: Custs.h:20: field `array_of_customers' has incomplete type Test.cpp:51: parse error at end of input *************************************************** customer.h ************************************************* //class customer header #ifndef CUSTOMER_H #define CUSTOMER_H class customer { public: customer(); ~customer(); int getnumber(); void setnumber(int); void display(); protected: int number; }; #endif ***************************************************** customer.cc ****************************************************** #include # include # include "Customer.h" //constructor customer::customer () { number = 2; } customer::~customer() { cout<<"in destructor"< #include "Customer.h" class customers { public: customers(); ~customers(); customer getCustomer(int i); void setCustomer(customer c,int i); private: customer array_of_customers[25]; } ******************************************* Custs.cc; ****************************************** #include"Custs.h" customers::customers() { } customer customers::getCustomer(int i) { cout<<"in getCustomer"< # include "Customer.h" # include "Custs.h" int main() { int a, b; customers shoppers; customer dave; dave.setnumber(7); dave.display(); cout<<"dave is a customer whose number is "; cout<< dave.getnumber() <>b; y.setnumber(b); //This is rather crude but it demonstrates the approach needed shoppers.setCustomer(dave,1); shoppers.setCustomer(x,2); shoppers.setCustomer(y,3); cout<<"first in array is"; shoppers.getCustomer(1); cout<<"second in array is"; shoppers.getCustomer(2); cout<<"third in array is"; shoppers.getCustomer(3); cout<>a; return 0; } { }