c++arraysstringrubiks-cube

using cout to print an string array not working


I have this code, which is supposed to cout an string of an array, but it doesn't do anything :/ also, when I run the .exe file itself it gives some errors of not finding basic_string in the file.

#include <iostream>
#include <string>
using namespace std;

//red is F-face, yellow is D-face
//B G O R W Y

class cube{
    public:
        string cubeCorners[8] = {"BOY", "GOY", "GRY", "BRY", "BOW", "GOW", "GRW", "BRW"};

        void U(){
            cout << cubeCorners[1];
            cubeCorners[2] = cubeCorners[3], cubeCorners[6] = cubeCorners[2], cubeCorners[7] = cubeCorners[6], cubeCorners[3] = cubeCorners[7];
        }
};

int main(){
    cube obj;
    obj.U();
    return 0;
}

How do I fix this, and what did I do wrong?


Solution

  • Some years ago when I was using MinGW, I got exactly the same kind of problem as you did. Whenever the code used any C++ standard library function, it could compile, but could not run.

    The problem was due to libstdc++ being installed incorrectly. A quick fix is to add -static-libstdc++ to your compiler option. However, to fully resolve the issue you have to reinstall your compiler and standard library.