So this is a little weird. Classes are technically abstractions in most tabletop games, that occasionally have overlap with the perceptions of people in game.
So in-game, you probably wouldn't go about making a class in the sense of a series of features and stats accured by gaining levels, because those levels are also an abstraction.
Your GM might insist on some kind of cost to enter a totally new homebrewed class that no one else in the world has. It might involve studying ancient manuals in order to learn a style of fighting, pilgrimage or participation in a religious ceremony to gain the favour of a particular extraplanar figure or practice and experimentation to develop a new kind of magic. Some prestige classes have had requirements that did have a monetary or material cost. Tome of Battle had one that required ingesting some amount of a metal if I remember.
As far as you making a new class, it's pretty simple.
First, you outline what kind of class this is and how many levels it has. If it's a class that you could enter at first level, this is typically 20. Prestige classes are typically 10, and able to be entered by their intended users at around level 7 or so. There's also been a few one-off classes that have been five levels long.
You decide what the basic chasis of this class is. That means determining what the progression of its Base Attack Bonus is, what hit die it uses (this is typically linked with the BAB), and what its saving throws are like. A monk, for example has all good saving throws. You also determine the class skills and skill points per level.
The generic classes here should provide you with a reasonable starting point for basing the numbers on. The warrior uses full bab (bab equal to level), the expert uses 3/4 bab, and the Spellcaster uses 1/2 BAB. They all have good and bad saving throw charts in there as well. Remember that BAB and Saving throws have strict progressions. When I've done homebrew in the past I usually just crib the appropriate numbers from a suitable class.
Then you assign your class features and the levels at which this class gains them. Feel free to borrow class features from other existing classes when you're doing this. It makes it a little easier to start with something that does work with the game rules and walk your way to where you want that to be, rather than trying to construct rules text out of whole cloth and finding it doesn't work quite the way you want.
If you're working with pathfinder classes, those are designed not to have what they call "dead levels". Basically this means a level where nothing happens other than your BAB, Saving Throw and Hit Points going up. Levels at which spellcasters gain a new level of spells are generally not considered dead levels. Try comparing the pathfinder fighter to the 3.5 fighter if you want a sense of what I'm talking about.
Lastly, run this class by your GM, and see what they think. The GM is ultimately going to be the arbiter of any new content in a game. If you're the GM, maybe ask your players what they think.
DO compare your finished product to other published classes, but don't worry if it's not a perfect result. People got paid to develop those classes.
Hope this helps.