Tuesday

Getting Started with C++ 2017 using gcc v6.1.0 32-bit

Steps are as follows:

Download gcc v6.1.0 32-bit from
ftp://ftp.equation.com/gcc/gcc-6.1.0-32.exe
Filename: gcc-6.1.0-32.exe

Install gcc 32-bit to "C:\gcc-6.1.0-32"

Please log off and log in again to configure the gcc for all users on this operating system.

Download and install Notepad++ from
https://notepad-plus-plus.org/download/

Open Notepad++
Save the new file as "cpp2017_eg1.cpp"

Filename: cpp2017_eg1.cpp
File content:
/********************/
#define __STDCPP_WANT_MATH_SPEC_FUNCS__ 1 //betaf(), beta()
#include <iostream>
#include <string>
#include <experimental/string_view>
#include <cmath>
using namespace std;

int main()

    cout << __cplusplus << endl; //201500

    //Hexadecimal literals
    int hex1 = 0xA;  
    cout << hex1 << endl; //10  
  
    experimental::string_view v = "hello world";
    v = v.substr(7);
    cout << v << endl; //orld

    //Mathematical special functions from C++ 2017
    cout << betaf(4.0f, 2.0f) << endl; //0.05

    int n = 4;
    int k = 2;
    cout << 1/( (n+1)*beta(n-k+1, k+1) ) << endl; //6
    // C(4,2)=4!/(2!2!)=4x3/2=6
  
    cout << expint(1) << endl; //1.89512, exponential integral
    cout << riemann_zeta(2) << endl; //1.64493          
  
    return 0;
}

/********************/

Program output: Open command prompt window

C:\my_folder_path> g++ --version
g++ (GCC) 6.1.0

C:\my_folder_path> g++ -std=c++17 cpp2017_eg1.cpp -o a.exe

C:\my_folder_path> a.exe
201500
10
orld
0.05
6
1.89512
1.64493

Step to uninstall GCC downloaded from
http://www.equation.com/servlet/equation.cmd?fa=fortran

* Open the system “Environment Variables” frame
* Delete the system variable named “EQ_LIBRARY_PATH” which contains the following variable value "C:\gcc-6.1.0-32\i686-pc-mingw32\lib"
* Delete the following two system path values from the system variable named “Path”:
*** "C:\gcc-6.1.0-32\bin;”
*** “C:\gcc-6.1.0-32\libexec\gcc\i686-pc-mingw32\6.1.0;"
* Delete the directory at “C:\gcc-6.1.0-32”

Friday

Qt C++: Solution for “error: variable 'QPointer label' has initializer but incomplete type”

Qt C++: Solution for “error: variable 'QPointer<QLabel> label' has initializer but incomplete type”

C++ Code with Error message:

void MainWindow::on_pushButton_clicked()
{
  QPointer<QLabel> label = ui->label1;

  label->setText("Label 1 text changed");
}

Solution:

You need to include the “#include <QPointer>“ at the top section in this implementation file.
 

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’.
 

If a hater attacked your age and not the goodness of you

Whether young or old, I've always been known what endures. I've known the very idea of people that were all created equal and deserv...