#define MY_CONST 7
class MyClass {
static const int my_const = 7;
// ...
};
class MyClass {
static const int my_const = 7;
enum {another_const = 7};
// ...
};
class MyClass {
enum {MY_CONST = 7};
// ...
};
const int constname = XXX;
extern const int constname;
const int constname = XXX;
// commdef.h文件
#ifndef LX_COMMDEF_H
#define LX_COMMDEF_H
const int MAX_LENGTH = 1024;
extern const int MIN_LENGTH;
#endif
// commdef.cpp文件
#include "commdef.h"
const int MIN_LENGTH = 10;
// test1.cpp文件(注:头文件内容由于简单所以省略掉了)
#include "commdef.h"
#include "test1.h"
#include <iostream>
using namespace std;
void FuncTest1()
{
cout << "MAX_LENGTH = " << MAX_LENGTH << ", address: " << &MAX_LENGTH << endl;
cout << "MIN_LENGTH = " << MIN_LENGTH << ", address: " << &MIN_LENGTH << endl;
}
// test2.cpp文件(注:头文件内容由于简单所以省略掉了)
#include "commdef.h"
#include "test1.h"
#include <iostream>
using namespace std;
void FuncTest2()
{
cout << "MAX_LENGTH = " << MAX_LENGTH << ", address: " << &MAX_LENGTH << endl;
cout << "MIN_LENGTH = " << MIN_LENGTH << ", address: " << &MIN_LENGTH << endl;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有