Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 02-26-2017, 02:26 AM   #1
Human being with feelings
Anomaly's Avatar
Join Date: Sep 2007
Posts: 642
Default Overriding a method..?


I'm just learning c++, so I hope my question is not ridiculous?
My dilemma is that I'd like to be able to programmatically override a method INSIDE a single class. Is this even possible?

Here is a pseudo-code example:
Class Processor {

	void SetUpProcessor(int choice) {
		if (choice == 0) {
			howToProcess = DoItThisWay();
		if (choice == 1) {
			howToProcess = DoItThatWay();

	double DoItThisWay(double input) {
		...blaa blaa

	double DoItThatWay(double input) {
		...blaa blaa

	double Process(double input) {
		return howToProcess(input);

Thanks for your patience
Sonic Anomaly | free JSFX & VST Plugins
Anomaly is offline   Reply With Quote
Old 02-26-2017, 09:06 AM   #2
Human being with feelings
Join Date: Feb 2014
Posts: 63

Look into function pointers in C++.
gstuff is offline   Reply With Quote
Old 02-26-2017, 09:37 AM   #3
Human being with feelings
Xenakios's Avatar
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,046

Originally Posted by gstuff View Post
Look into function pointers in C++.
Or just do the choice of processing function inside the audio processing function itself. I'd guess the performance overhead is about the same between using a function pointer or doing a branch. (At least if the compiler is able to inline the called functions...)
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
Xenakios is offline   Reply With Quote

Thread Tools
Display Modes

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 -7. The time now is 05:37 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.