Teach me how to write two functions in other file
I use visual c++ 6.0 enviorment. The primary file which contain main is 555.cpp. I also wrote two functions in r.h and r.cpp. I want to call these two functions in 555.cpp. However, it always show some error. Is there anyone who can teach me how to fix this problem? Thanks
***error message***
Compiling...
555.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\555\555.cpp(12) : error C2065: 'AA' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\555\555.cpp(13) : error C2065: 'BB' : undeclared identifier
r.cpp
c:\program files\microsoft visual studio\myprojects\111\r.cpp(21) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Generating Code...
Error executing cl.exe.
555.exe - 3 error(s), 0 warning(s)
***555.cpp***
#include "stdafx.h"
#include "r.h"
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, char* argv[])
{
double a=AA();
double b=BB();
cout << a;
cout << b;
return 0;
}
***r.h***
#ifndef RANDOM1_H
#define RANDOM1_H
double AA();
double BB();
#endif
***r.cpp***
//test
#include <cstdlib>
#include <cmath>
#include "r.h"
// the basic math functions should be in namespace
// std but aren't in VCPP6
#if !defined(_MSC_VER)
using namespace std;
#endif
double AA()
{
return 3.3;
}
double GetOneGaussianByBoxMuller()
{
return 4.4;
}
|