Friday

Qt C++: Solution for “error: only constructors take member initializers” and “warning: no return statement in function returning non-void [-Wreturn-type]”

Qt C++: Solution for “error: only constructors take member initializers” and “warning: no return statement in function returning non-void [-Wreturn-type]”

C++ Code with Error and Warning messages:

class ClassName
{
private:
  QString s;
  double d;
public:
  ClassKName(QString s="noName", double d=0.0) : s(s), d(d)
  {
  }
};

Solution:

The constructor name is different from the class name.
Rename the constructor name ClassKName to be the same with ClassName without the extra letter ‘K’.
 

No comments:

Measure execution time with Julia, example using sorting algorithms

# random integers between 1 and 100 inclusive, generate thousands of them x = rand ( 1 : 100 , 100000 ) @time sort (x; alg=InsertionSort, r...