I have already looked at this question. This is the error message I receive:
E0304 no instance of overloaded function "std::vector<_Ty, _Alloc>::push_back [with _Ty=void (*)(), _Alloc=std::allocator<void (*)()>]" matches the argument list
My goal is to get all pointers to function in a vector so I can loop through them for various datasets by testing the different sorting algorithms My code:
#include <iostream>
#include <fstream>
#include <chrono>
using namespace std;
#ifndef Sort_h
#define Sort_h
class Sort : public Algorithm
{
public:
Sort() {
algorithms.push_back((sortalgorithms::bubble));
//algorithms.push_back(&(sortalgorithms::merge));
//algorithms.push_back(&(sortalgorithms::insertion));
}
~Sort();
void load(string);
void execute();
void display();
void stats();
void select(int);
void save();
void configure();
private:
int type = 0;
vector<int> data;
string sortname;
int vecSize = 0;
string fileName;
chrono::duration<double> time;
std::vector<void (*)()> algorithms;
};
#endif
#pragma once
#include "Algorithm.h"
#include <string>
#ifndef algorithm_h
#define algorithm_h
using namespace std;
class Algorithm {
public:
Algorithm() {};
virtual ~Algorithm() {};
virtual void load(string) = 0;
virtual void execute() = 0;
virtual void display() = 0;
virtual void stats() = 0;
virtual void select() = 0;
virtual void save() = 0;
virtual void configure() = 0;
};
#endif algorithm_h
I want to call a function from a vector of function pointers.