Hi,

I have a function which I need in different source files again and again. So I thought implementing it in an own class (Defaults) as static function. I have

Code:
//Defaults.h
#ifndef DEFAULTS_H
#define DEFAULTS_H

class Defaults
{
  public:
  static const double c;
  static void read();
};

#endif
and

Code:
//defaults.cpp
#include "defaults.h"
#include <iostream>

using namespace std;

static void Defaults::read() //this is line no. 6
{
  cout << "static read";
}
And then somewhere in my code I want to do:

Code:
//some other class.cpp
#include "mainwindow.h"
#include "defaults.h"
#include <iostream>

using namespace std;

MainWindow::MainWindow() 
{
cout << "construtctor mainwindow"; 
cout << Defaults::c; // c was set before this works

Defaults::read(); // this doesn't work
}
When trying to compile I get

defaults.cpp:6: error: cannot declare member function ‘static void Defaults::read()’ to have static linkage
So what is wrong here?

Apart from the bug itself here, is that the right way to achieve what I want to achieve?

Thanks, J.