Class++ | Classes and OOP made easy and powerful with Access Specifiers, function overloading and more!

Looks great. I’ll use this for my new project game :grin::ok_hand:, btw nice work :heart_eyes:

1 Like

Currently I’m just using the “Snippets! Autocomplete” plugin with ClassPP for my game framework. It is the most simple and easy to use plugin because all you have to do is edit a script in ServerStorage to create/modify a snippet. You should give it a try. I recommend a script-based approach instead of forcing users to adhere to a specific format as is shown in your screenshot.

Someone recommended that to me above and I checked it out, it’s pretty nice. However, this plugin is designed to create class autocompletes, and also provide other functions that I’ve listed above. It’s not a simple autocomplete plugin. (You might consider it a glorified donation system with the full version)

Also, you will be able to put code in the full version with other benefits. The demo(free) version is just for people who don’t want to spend time coding and just be able to easily create class snippets that work.

2 Likes

Its the best thing I ever saw on this forum!

1 Like

Hi! Thanks for Class++ - it’s seriously cool! I checked out the code, and I can see you’ve really made creating classes in Roblox much easier. The operator & function overloading is awesome - makes everything way more expressive!
The classes that are created by this module are much easier to make SOLIDes
(in my language, this is an adjective like “cool”, which has the same root as in the SOLID. It’s a pity that translator didn’t transfer to English.)

In addition, Class++ greatly simplifies code organization and component reuse. Thanks to the built-in inheritance system (instead of the meta-label pattern🤮) and lightweight, typed encapsulation (instead of the __(nev) index), your code becomes more structured and easier to understand.

1 Like

Coming Soon to Class++, full auto type-completion for objects:

image

It will also support the new inheritance system I’m currently working on. Stay tuned as a lot of things are coming soon. (v2.0.0)

2 Likes

Release 1.2.1


Sorry for the long wait between updates. I was waiting for the new type solver to be stable enough to make a whole new re-write version of Class++, but since it’s taking a long time, I decided to release a small update with bug fixes for now.

  • Fixed overloaded functions not being able to access Private or Protected members of their class.
  • Fixed #2.
  • Fixed Class++ allowing a member to be set to nil. This creates problems where when that member is set to nil, it no longer exists within the objectData, thus it not being able to be set again later.
  • Class++ now automatically creates certain access specifiers internally, so you don’t have to declare empty access specifiers in the classData table in order to create functions with the outside class definition.
  • Class++ now warns you if you’re using methods that will be changed/removed in a future update. This can be silenced by setting the silenceUpdateWarning attribute in the module instance to true.
  • Changed the default module name when imported from the .rbxm file from “Class++” to “ClassPP” to increase compatibility.

More info on the upcoming update:


Currently, I’m working on the version 2.0.0 of Class++, this is a whole re-write with full support for the new type solver. It will also contain a bunch of very cool features such as multi-inheritance, automatic destructor calls, and more quality of life stuff.

I’ve also made a new GitHub discussions page, where I’ll be revealing and talking about the new features I want to add to Class++, so I’d be really glad if you’d check it out. I like hearing feedback from all of you.

3 Likes

Here’s another teaser for 2.0, class function is now overloadable.

image (2)

3 Likes

Hey, I was using this but could not find the way to access a function in the super class (like the python super() keyword). Is there functionality for this?

Not yet, but in the next update it will be implemented. You can see the discussions page on GitHub in the above post for more information.

2 Likes

Hello. I made another discussion post where I talked about a major upcoming change to Class++ to increase memory efficiency.

Would love to hear your thoughts, you can also reply here.

2 Likes

I’ve found many really usefull resources on dev forum that I use to make the developement of my projects faster. But that one might be one of the greatest, this is just paradise for I and probably much others that knows C++.Thank you for this

1 Like

Any ETA on when this will be available for the new solver? Really looking forward to using this on my projects but i’m unsure if I should start with the current version or just wait for 2.0.

Also off-topic but I really liked the docs website and i’m using it as reference for my own, so huge props for that.
1 Like

2.0.0 will take a while to get out, due to the new solver still being unstable. It is becoming more and more usable every week, but not there yet.

A beta version is coming out in the next week with certain features, though I’d still recommend you go with 1.2.1 for now. It’s the most stable and finished version.

Also, thanks. Docs will recieve an update with 2.0.0, a new theme with some rewording to be more consistent.

1 Like

Good stuff, especially for someone like me who hates looking at Metatables.

1 Like

Will Beta Version contain the types feature (at least a somewhat working version)? Thanks :pray:

hello, im having trouble with the Friend Access Specifier.
i try to make class1 access class2’s private members.
i end up getting “{Class++}: Cannot call function directly.” error instead.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ClassPP = require(ReplicatedStorage["Class++"])

local class = ClassPP.class

local Car = class "Car" {
	Public = {
		Brand = "Lamborghini",
		ask_for_license_plate = function(self, object:any)
			print(object.License_Plate)
		end
	},
	Private = {
		License_Plate = "XXXX",
	},
	Friend = {
		"Other Car"
	},
}

local OtherCar = class "Other Car" {
	Public = {
		Brand = "Ferrari",
		ask_for_license_plate = function(self, object:any)
			print(object.License_Plate)
		end
	},
	Private = {
		License_Plate = "XXXX",
	},
	Friend = {
		"Car"
	},

}

local newCar = Car.new()
local newOtherCar = OtherCar.new()

newCar:ask_for_license_plate(newOtherCar)
newOtherCar:ask_for_license_plate(newCar)

Yeah, unfortunately this is a bug. I’ve fixed it and will be including it to the next version of Class++.
For now, you can work around this issue by making the license plate function a friend function instead.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ClassPP = require(ReplicatedStorage["Class++"])

local class = ClassPP.class

local function ask_for_license_plate(object: any)
	print(object.License_Plate)
end

local Car = class "Car" {
	Public = {
		Brand = "Lamborghini"
	},
	Private = {
		License_Plate = "XXXX",
	},
	Friend = {
		ask_for_license_plate
	},
}

local OtherCar = class "Other Car" {
	Public = {
		Brand = "Ferrari"
	},
	Private = {
		License_Plate = "XXXX",
	},
	Friend = {
		ask_for_license_plate
	},

}

local newCar = Car.new()
local newOtherCar = OtherCar.new()

ask_for_license_plate(newOtherCar)
ask_for_license_plate(newCar)
1 Like

The first beta version will contain automatic type creation depending on the classData.
This means that you will be able to get type-checking easily for classes within classes, or objects within objects.

2 Likes

Release Version 0.0.1 (New Type Solver Beta)


Hello everyone! This update is about the new re-write of Class++ for the new type solver. This is one of the many updates that will come, so stay tuned.

  • The module has been re-written from the ground up.
    • Main module has been re-written to support the new type solver, and allow for a better experience using Class++.
    • The main API Surface is the same, however certain method behaviors have changed.
    • Replaced the Error API with a much better and expandable Log API.
    • Updated the Type API to make it more compatible and stable (it can even be used as a replacement for built-in type methods), however, method names are changed.
  • Updated Inheritance (Part 1)
    • Removed class.extends method and instead merged the functionality with the class method of the main API.
    • Class++ now supports multi-inheritance.
    • Constructor calling mechanism has been revamped to fix bugs related to parent class constructors not being called properly.
    • Inherited classes now have proper type-checking with the new type solver, this also includes objects.
  • Replacing the Error API with Log API
    • To make debugging easier, Class++ error messages are now more consistent in style and easier to read, and they will now provide links (in Studio) to find more information about the error.
    • Certain error messages now provide more information to make debugging easier.
  • Type API is now more stable and compatible
    • The old Type.typeof() and Type.typeofClass() methods have been replaced with Type.type() and Type.typeof() methods that are more compatible with Luau’s built in type() and typeof() functions. You can even replace the built-in methods with the new Type API methods, and they will still work! (Type API provides type support for class and object userdatas.)
  • Major bug fixes
    • Fixed Friend access specifier not using the class references properly to allow other classes access to Private and Protected members.
    • Fixed overloaded functions not being able to access Private and Protected members of their class.
    • Fixed bugs related to being able to set a class member to nil.
    • Fixed bugs related to inheritance.

:warning: Notes:

  • Because the new type solver is still in beta, certain type-related features may stop working or cause bugs. And even though the new solver is far more capable than the old one, it’s still limited in certain places. That’s why if you encounter an issue, please make a bug report.
    (Due to this, it is not recommended to use this version in production.)
  • This release only contains a certain part of the announced/planned features from the discussions page. Rest of the planned features and more will come soon.

:exclamation: Since this is a beta that relies heavily on the New Type Solver, you must enable it from Beta Features in order to use this version of Class++.
And due to this version being a beta, the download is only on the github page.

2 Likes