2

I get this error when I compile this code in my compiler. I tested this code in VSCode and I didn't get any error but in 'codeblocks' IDE, I get this error:

ERROR: undefined reference to 'Image::numbers'

This is my code:

note: I don't write those pieces of my code which they are not so important to solve my problem, like 'getWidth() function' etc.

#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;
class Image
{
private:
    static vector < vector < vector<bool> > > numbers;
    static void setImageMatrix(ifstream& image, vector< vector< vector<bool> > > &matrix, int index)
    {
        int width = getWidth(image);
        int height = getHeight(image);
        int zeros = getNumberOfZeros(width);
        int lineCharsNumber = width * 3 + zeros;
        char pixelsLine[lineCharsNumber];

        int end = width*3;
        vector <bool> tempVector;
        for(int i = 0; i < height; i++)
        {
            image.read(pixelsLine, lineCharsNumber);

            tempVector.clear();
            for (int j = 0; j < end; j+=3)
            {
                int average = charToInt(pixelsLine[j]) * 0.11 + charToInt(pixelsLine[j+1]) * 0.59
                + charToInt(pixelsLine[j+2]) * 0.3;

                if(average < 70)
                    tempVector.push_back(true);
                else
                    tempVector.push_back(false);
            }
            matrix[index].push_back(tempVector);
        }
    }

    void static setNumbersMatrix()
    {
        ifstream zeroPic("F:\\Projects\\C++\\-[Project1]Image_Processing\\Images\\0.bmp", ios::in | ios::binary);
        setImageMatrix(zeroPic, numbers, 0);
    }

and at last: sorry about my English, I appreciate that if you help me, thanks!

Christophe
  • 68,716
  • 7
  • 72
  • 138

0 Answers0