知识库

C++语言开发示例:07. 两个文件

2025-02-01 20:32:17 李腾 1 次阅读

twofile1.cpp

#include <iostream>

int tom = 3;
int dick = 30;
static int harry = 300;

void remote_access();

int main()
{
    using namespace std;
    cout << "main() reports the following addresses:\n";
    cout << &tom << " = &tom, " << &dick << " = &dick, ";
    cout << &harry << " = &harry\n";
    remote_access();
}

twofile2.cpp

#include <iostream>
extern int tom;
static int dick = 10;
int harry = 200;

void remote_access()
{
    using namespace std;
    cout << "remote_access() reports the following addresses:\n";
    cout << &tom << " = &tom, " << &dick << " = &dick, ";
    cout << &harry << " = &harry\n";
}
转载请注明转自www.hylab.cn,原文地址:C++语言开发示例:07. 两个文件

评论 (0)

登录后发表评论

暂无评论,快来发表第一条评论吧!