Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
|
Visual C++ Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 12th, 2006, 10:52 AM
Registered User
 
Join Date: Jan 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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;
}






Similar Threads
Thread Thread Starter Forum Replies Last Post
Teach me please :) AdnanAhsan CSS Cascading Style Sheets 1 December 5th, 2007 10:06 AM
Teach me how to create an ERB using sql server2005 Byock SQL Language 4 July 12th, 2007 08:13 AM
Plz Teach Me...Thanks ck C++ Programming 0 January 7th, 2005 04:56 AM
reading HTML from file -> write to file mikeuk Beginning PHP 4 July 21st, 2004 05:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.