C++ Using inheritance to tweak an algorithm
问题 Since Dijkstra's algorithm and Prim's algorithm are so similar, I'd like to make a base algorithm class (I'll call it "Greedy" or something) and then I want to inherit from Greedy and tweak the algorithm based on the class. I think it boils down to this. I'd like to reuse a large portion of an algorithm but tweak an operation or two. class BaseAlg { public: BaseAlg(std::vector<int> data) //constructor sums a vector and stores result { int accum = 0; for (unsigned int i = 0; i < data.size(); +