You should not use the class qualifier A:: in the declaration of your member function.
If you want to move the definition of your member function outside the class declaration then you add the class qualifier, but you only use the static keyword in the declaration (in the class) and not in the definition:
#include <iostream>
class A
{
staticint count;
public:
A()
{
count++;
}
// Do not add A:: qualifier here
staticvoid countobjects(); // no need for void parameter
};
// define static member data and functions here
// Note, do NOT use the static keyword, only in
// the declaration in the class
int A::count = 0;
void A::countobjects() // no need for void parameter
{
std::cout << "Number of objects=" << count << std::endl;
}
int main()
{
A test;
A::countobjects();
}