Path: csiph.com!aioe.org!.POSTED!not-for-mail From: Kaz Kylheku <330-706-9395@kylheku.com> Newsgroups: comp.programming Subject: Re: Designing a suite of algorithms in C++ Date: Mon, 1 Feb 2016 23:24:53 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 23 Message-ID: <20160201151941.461@kylheku.com> References: <2df6fc12-e6c9-4f5b-bdb7-21e35a57edbb@googlegroups.com> NNTP-Posting-Host: OGJi3KNpFOhM58UHZwXj0w.user.gioia.aioe.org X-Complaints-To: abuse@aioe.org User-Agent: slrn/pre1.0.0-18 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.programming:6255 On 2016-02-01, Paul wrote: > class Algorithm{ > > public: > Algorithm(some parameters); > virtual void findSolution() = 0; > virtual ~Algorithm() > {} > }; This interface only supports algorithms that either find a solution, for any combination of parameters, or else do not terminate. Your findSolution function has no way to indicate "I have stopped searching, and found no solution". If the function returns, since it has no return value, and the interface has no useful member functions to inspect any state, we can assume that the solution was found. So if the solution cannot be found, the function doesn't return, right? Not to mention that, quite often, when algorithms find a solution, we want to know *what* that solution is, not only *that* it exists.