Originally Posted by
laserlight
Well, one problem is that you gailed to declare and define Memoryx::que with a return type, e.g., void. Another problem is that Memoryx::que is a non-static member function, so it should be called from a Memoryx object. You also should #include <cstdio> in Memoryx.cpp in order to use printf, which should be qualified as std:
rintf.
By the way, names that begin with an underscore followed by an uppercase letter, or that contain consecutive underscores, are reserved to the (compiler and standard library) implementation for any use. Therefore, instead of using __MEMORYX_H__ for the header inclusion guard, use say, MEMORYX_H_.
Also, the global main function normally returns 0 upon successful execution.
New code, but still, it's not working :/
main.cpp
Code:
#include <iostream>
#include <cstdio>
#include "Memoryx.cpp"
int main(){
Memoryx::que();
return 0;
}
Memoryx.cpp
Code:
#include <cstdio>
#include "Memoryx.h"
static void Memoryx::que(){
std::printf("aaa");
}
Memoryx.h
Code:
#ifndef MEMORYX_H_
#define MEMORYX_H_
class Memoryx{
public:
static void que();
};
#endif
Error:
Code:
Compiler: Default compiler
Building Makefile: "C:\Documents and Settings\robdah01\Skrivbord\classtest\Makefile.win"
Executing make...
make.exe -f "C:\Documents and Settings\robdah01\Skrivbord\classtest\Makefile.win" all
g++.exe -c Memoryx.cpp -o Memoryx.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"
Memoryx.cpp:4: error: cannot declare member function `static void Memoryx::que()' to have static linkage
make.exe: *** [Memoryx.o] Error 1
Execution terminated