Making a library: I must be missing some steps...

I looked at the example at Arduino Playground - Library Tutorial and there is some mention there about compiling the .h and .cpp file and an object file that must be deleted if the source is changed. Now, compile with what? I guess the IDE does not generate object files...

I coded a simple .h and .cpp file in notepad then tried to import it into the sketch I have in Arduino IDE 022. Is this not possible?

I get these errors when I try to run the below sketch:

testclass:-1: error: new types may not be defined in a return type
testclass.cpp:3: note: (perhaps a semicolon is missing after the definition of 'testclass')
testclass:-1: error: two or more data types in declaration of 'setup'
testclass.cpp: In function 'void setup()':
testclass:4: error: request for member 'addnum' in 'tc', which is of non-class type 'testclass ()()'

testclass.h:

#ifndef testclass_h
#define testclass_h

#include <WProgram.h>

class testclass{
   public:
      testclass();
      int addnum(int a, int b);
}
#endif

testclass.cpp:

#include <testclass.h>

testclass::testclass(){}

int testclass::addnum(int a, int b)
{
   return (a+b);
}

Sketch:

#include <testclass.h>
testclass tc();

void setup(){
tc.addnum(1,1);
}

void loop(){

}

Somebody please enlighten me!

Old guy.

testclass tc();

Do you mean:

testclass tc;

... and don't ignore this error:

Old_guy:
testclass:-1: error: new types may not be defined in a return type
testclass.cpp:3: note: (perhaps a semicolon is missing after the definition of 'testclass')

You're missing a semi-colon:

Old_guy:
testclass.h:

#ifndef testclass_h

#define testclass_h

#include <WProgram.h>

class testclass{
   public:
      testclass();
      int addnum(int a, int b);
}; // semi-colon required
#endif

!c

Thanks guys! Another set of eyes is always a good thing! I will eventually get up to speed...

Old guy.