Raised This Month: $51 Target: $400
 12% 

Polymorphism Function


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ilham92-cc-sakura
Senior Member
Join Date: Oct 2008
Location: /var/www/index.html
Old 01-23-2022 , 04:34   Polymorphism Function
Reply With Quote #1

Do SourcePawn support "Polymorphism"? Make code writing easier like C, C++, C#, Java.

PHP Code:
void L4D2_SpawnInfected(int class)
{
    
// Spawn a bot
}

void L4D2_SpawnInfected(int playerint class)
{
    
// Spawn as player

__________________
ilham92-cc-sakura is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 01-24-2022 , 10:39   Re: Polymorphism Function
Reply With Quote #2

SourcePawn is not like C++ (the only similarity is probably syntax) and other OOLs.
There can be only one function L4D2_SpawnInfected with only one prototype.

You can define typesets (a set of typedefs with one name and typedef is not the same as in C/C++) but they're used as callbacks and you have to handle (choose which one to use in different cases) them manually.

About typeset and typedef: https://wiki.alliedmods.net/SourcePa...yntax#Typedefs
An example of typedef: https://wiki.alliedmods.net/Function...ivate_Forwards
__________________
MAGNAT2645 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:38.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode