jeudi 5 mai 2016

how to call Class static member of variable in function using c++11 [duplicate]

This question already has an answer here:

When I try to call static variable it gives me error. I have been searching on internet for couple hours to be honest I am not exactly sure what I am missing really.

`

Error 1 error LNK2001: unresolved external symbol "private: static class std::list > Sorting::boolList" (?boolList@Sorting@@0V?$list@_NV?$allocator@_N@std@@@std@@A) c:\Users\mac-windows\documents\visual studio 2013\Projects\SortingBuffer\SortingBuffer\Sorting.obj SortingBuffer

`

this is my Sorting.cpp

#include "Sorting.h"
#include <bitset>
#include <iostream>
using namespace std;

void Sorting::Process()
{
        for (auto litem : Sorting::boolList)
        {
            //do some stuff
        }
}

this is my Sorting.h

> #ifndef SORTING_H
> #define SORTING_H
> #include <list>
> #include <map>
> 
> class Sorting {
> 
> public:   static void Sorting::Process();
> 
> private:  static std::list<bool> boolList; };
> 
> #endif

and this is my main.cpp

#include <iostream>
#include "Sorting.h"

using namespace std;
int main() {


    cout << "anar";
}

Aucun commentaire:

Enregistrer un commentaire