How to add a custom library?

I'm creating a project with some use of an instruction online where he uses <waypointClass.h> as a library and when i use <waypointClass.h> i get an error of course because it doesn't know what that means. I have the code for it and that is all. I read something about needing a c or c++ file and maybe some other files idk. How do I go about this. Here is the code

class  waypointClass
{
    
  public:
    waypointClass(float pLong = 0, float pLat = 0)
      {
        fLong = pLong;
        fLat = pLat;
      }
      
    float getLat(void) {return fLat;}
    float getLong(void) {return fLong;}

  private:
    float fLong, fLat;
      
  
};  // waypointClass


// usage as array: 
//waypointClass myWaypoints[4] = {waypointClass(1,2), waypointClass(2,3), waypointClass(4,5), waypointClass() };

I place them in the library folder under the arduino folder where my sketches are located

for your case it would be C:\Users\you\Documents\Arduino\libraries\waypointClass\waypointClass.h
and all the other files associated with waypointClass.h in the same directory

now save your sketch and restart the arduino editor
your #include <waypointClass.h> should be found by the compiler

There are other options but this is the most common unless you plan on altering waypointClass.h files then you could put it in the same folder as your sketch.

This compiles fine:-

The class header:-

#ifndef _WAYPOINTCLASS_H    // This stops the compiler trying to include the header multiple times.
#define _WAYPOINTCLASS_H    // (Not strictly necessary in this case, but it is if the function definitions are in a separate *.cpp file.)

class  waypointClass
{
    public:
        waypointClass(float pLong = 0, float pLat = 0)
        {
            fLong = pLong;
            fLat = pLat;
        }

        float getLat(void)
        {
            return fLat;
        }

        float getLong(void)
        {
            return fLong;
        }

    private:
        float fLong, fLat;

};  // waypointClass

#endif // _WAYPOINTCLASS_H

The *.ino file:-

#include "waypointClass.h"      // Use this if the class header is in your project folder
//#include <waypointClass.h>    // Use this if the class header is in your "libraries" folder

waypointClass myWaypoints[4] = {waypointClass(1, 2), waypointClass(2, 3), waypointClass(4, 5), waypointClass() };

void setup() {}

void loop() {}

Here's a better test of your class. Set the serial baud rate to match that of your serial monitor, (or vice versa):-

#include "waypointClass.h"      // Use this if the class header is in your project folder
//#include <waypointClass.h>    // Use this if the class header is in your "libraries" folder

waypointClass myWaypoints[4] = {waypointClass(1, 2), waypointClass(2, 3), waypointClass(4, 5), waypointClass() };

void setup()
{
    Serial.begin(115200);
    float longitude = myWaypoints[0].getLong();
    Serial.print("myWaypoints[0] longitude = ");
    Serial.println(longitude);
}

void loop() {}

And a final point - always place your third-party libraries in the "libraries" folder located in your sketchbook, not in the main Arduino "libraries" folder. (As pointed out by zhomeslice.)

If you place them in the main Arduino "libraries" folder, they will be deleted when you update to a later version of the IDE, whereas the sketchbook is not removed in this process.

I appreciate the help and I'm pretty new and tried to understand it as best as possible but I'm still having issues. I created a new folder under my libraries folder with a couple other libraries that I downloaded from the search thing that had those libraries in it and I think I downloaded one from git hub or something. This one there was no download just the code. Im not sure if it was the main library or the sketch u mentioned its just the libraries folder. But I created a new folder in libraries called waypointClass. Then I dragged a copy of the code and dropped it into the folder. Restored Arduino and I still had the error for the waypointClass. Idk what an ino file or other file is that u were talking about I just have this code that the guy used in his project that I want to incorporate into mine. Hopefully someone can clear up some of these continued issues. Thanks again!

class  waypointClass
{
    
  public:
    waypointClass(float pLong = 0, float pLat = 0)
      {
        fLong = pLong;
        fLat = pLat;
      }
      
    float getLat(void) {return fLat;}
    float getLong(void) {return fLong;}

  private:
    float fLong, fLat;
      
  
};  // waypointClass


// usage as array: 
//waypointClass myWaypoints[4] = {waypointClass(1,2), waypointClass(2,3), waypointClass(4,5), waypointClass() };

SOLVED. I actually think I figured it out. Instead of dragging the copy of the code into the folder I had to drag a copy that I downloaded earlier with the arduino icon beside it.

Jordanar:
Idk what an ino file or other file is that u were talking about

The sketch is an *.ino file. When you save a sketch from the IDE, it's automatically given the .ino filename extension. Didn't you notice that the *.ino file I posted contained the 'setup()' and 'loop()' functions, as well as the #include for your header file? (A .h file is a header file.)