Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help needed understanding OOP

Status
Not open for further replies.

lloydie2

Programmer
Apr 21, 2003
75
GB
I am teaching myself Delphi and I am having a problem with OOP. I am trying to create a new class, but keep getting an error message, even though I am following the example int he book.

this is the code which is in a new unit:
--------------------------------------------
unit Unit2;

interface

type
Temployee = class
Name: char;
salaryToDate: integer;
procedure upDate(salUpdate: integer);
end;

implementation

end.
-----------------------------------------------
the error I get is:
-----------------------------------------------
[Error] Unit2.pas(9): Unsatisfied forward or external declaration: 'Temployee.upDate'
[Fatal Error] Project1.dpr(6): Could not compile used unit 'Unit2.pas'
-----------------------------------------------
Can you help

 
The compiler is reminding you that you have only declared the interface for your class. You have defined a procedure, but you have not implemented (written code for) it. That is what the implementation section is for.

If you put the cursor on the line where you say
Code:
  procedure upDate(salUpdate:integer);
and press <Ctrl>+<Shift>+C the IDE will create a skeleton procedure for you in the implementaion section. But you still need to supply the code. (You don't have to use this feature, but you need to get the code in there somehow and it is a handy feature.)

 
Thanx Zathras,
I was just trying to take the step by step approach in writing the class and didn't understand the error Msg.
Thanx
 
IIoydie2's request is an excellent example on how to ask for help from a forum like this:-

He briefly indicates level of experience.

He briefly describes his problem but includes all the relevant information including full details of the error message.

The result is that Zathras' solution addresses the problem perfectly.

Some requests for help seem to be along the lines of

&quot;I tried to write a class but it didn't work. Help me.&quot;

which can be so frustrating for someone wanting to help because there is no precise indication of what the problem actually is.

Andrew





 
Agreed, towerbase...

Another point - the title of the question is relevant to the content.

Someone browsing the forum, who has experience with OOP will
likely take a look at this question and try to help.

And later, if someone has a similar question, they will see
the title and *possibly* find the answer here without posting
the same question again.

Looking at the current titles on the first page of this forum,
I see a question titled :
&quot;Its driving me crazy, please help me&quot;
and another one titled :
&quot;2 questions&quot;

IMHO, questions with titles like that don't deserve an answer!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top