Horje
private static c++ Code Example
private static c++
#ifndef Foo_h
#define Foo_h

class Foo
{
  static const int a = 42; // OK
  static const int b {7};  // OK
  //static int x = 42; // ISO C++ forbids in-class initialization of non-const static member 'Foo::x'
  //static int y {7};  // ISO C++ forbids in-class initialization of non-const static member 'Foo::x'
  static int x;
  static int y;
  int m = 42;
  int n {7};
};

// Foo::x = 42;  // error: 'int Foo::x' is private
int Foo::x = 42; // OK in Foo.h if included in only one  *.cpp -> *.o file!
int Foo::y {7};  // OK

// int Foo::y {7};  // error: redefinition of 'int Foo::y'
   // ONLY if the compiler can see both declarations at the same time it, 
   // OTHERWISE you get a linker error

#endif // Foo_h
private static c++
class foo
{
    private:
        static int const i = 42;
};




Cpp

Related
& before function arg in cpp Code Example & before function arg in cpp Code Example
c++ uint8_t header Code Example c++ uint8_t header Code Example
c to c++ online converter Code Example c to c++ online converter Code Example
how to make dictionary of numbers in c++ Code Example how to make dictionary of numbers in c++ Code Example
linux c++ sigint handler Code Example linux c++ sigint handler Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7