jeudi 19 décembre 2019

undefined reference to `tempclass::var6' in C++ [duplicate]

This question already has an answer here:

I am new to the C++ programming and during my venture with it I came across the usage of 'static' storage class usage among class; however while running some test-code for the understanding purpose I came across some error which is not making any sense(yet). Kindly let me know what am I missing.

#include <iostream>

class tempclass
{
public:
    static int var6;
    int var7;
};

int main()
{
    tempclass::var6 = 99;
    std::cout << "the static value is " << tempclass::var6 << endl;
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire