Skip to content

Instantly share code, notes, and snippets.

@prestonvasquez
Created February 14, 2023 04:50
Show Gist options
  • Save prestonvasquez/e660195f8417de03446330d2a0b68bfe to your computer and use it in GitHub Desktop.
Save prestonvasquez/e660195f8417de03446330d2a0b68bfe to your computer and use it in GitHub Desktop.
#include <iostream>
#include <type_traits>
using namespace std;
// Derived classes
class Human {
public:
static int getMove() {
// TODO: add logic
return 1;
}
};
class Computer {
public:
static int getMove() {
// TODO: add logic
return 0;
}
};
template <typename F>
int battle(F p1, F p2) {
return p1() + p2();
}
int main(void) {
Human p1;
Computer p2;
cout << "value: " << battle(p1.getMove, p2.getMove) << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment