C++之父新作里#include"std_lib_facilities.h"

dixiad 2010-09-27 09:19:24
#include"std_lib_facilities.h"是什么头文件那?在c free里说找不到这个文件
...全文
1058 15 打赏 收藏 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
ForestDB 2010-09-28
  • 打赏
  • 举报
回复
LZ一定是看书的时候跳着看的。
书中有下载的地址。
hongwenjun 2010-09-28
  • 打赏
  • 举报
回复
"xxx.h" 基本就是自定义了
<xxxxxx> C++编译带的库
或者 安装的其他库
dixiad 2010-09-28
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 binbin1129 的回复:]
楼主大哥。。。
这本书叫什么名???
[/Quote]
Programming -- Principles and Practice Using C++
中文版叫c++程序设计原理与实践
binbin1129 2010-09-28
  • 打赏
  • 举报
回复
楼主大哥。。。
这本书叫什么名???
dixiad 2010-09-28
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 forestdb 的回复:]
LZ一定是看书的时候跳着看的。
书中有下载的地址。
[/Quote]
嗯,我是跳着看的
Rainqin123 2010-09-27
  • 打赏
  • 举报
回复
全错.....比如#include“stdafx.h"(大概是这样)控制台程序少了它一点都不行....
dixiad 2010-09-27
  • 打赏
  • 举报
回复
那不是没它的光盘就没法用了?
GARY 2010-09-27
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 hslinux 的回复:]
没见过这个文件,一般来说
<XXXX.h>,也就是中括号括起来的头文件是系统路径中存在的头文件,
"XXXX.h",也就是双引号引用的头文件为用户项目中自定义的头文件。

所以LZ说的文件有可能是C++之父这个牛人自定义的一个头文件。。。。。。
[/Quote]
楼上所言极是。
hslinux 2010-09-27
  • 打赏
  • 举报
回复
没见过这个文件,一般来说
<XXXX.h>,也就是中括号括起来的头文件是系统路径中存在的头文件,
"XXXX.h",也就是双引号引用的头文件为用户项目中自定义的头文件。

所以LZ说的文件有可能是C++之父这个牛人自定义的一个头文件。。。。。。
  • 打赏
  • 举报
回复
是他自己定义的头文件
ericming200409 2010-09-27
  • 打赏
  • 举报
回复
楼主需要补充一下对头文件的理解咯
1 头文件是在预处理的时候才有的概念,预处理器将头文件包含到相应位置,对于编译器来讲,是没有头文件这个概念的。
2 请注意#include<XXX.h> 和 #include "XXX.h"的区别,对于这两种包含头文件的方式,预处理器的搜索方式不一样,""方式下是会先搜索当前目录的,所以一般标示为""的都可以考虑是不是在当然目录,当然也可以不是在当前目录,但是如果是标准库之类的,一般都是用<>,因为没必要先搜索当前目录浪费时间嘛
dixiad 2010-09-27
  • 打赏
  • 举报
回复
这个是stroustrup主页的std_lib_facilities.h文件

/*
simple "Programming: Principles and Practice using C++" course header to
be used for the first few weeks.
It provides the most common standard headers (in the global namespace)
and minimal exception/error support.

Students: please don't try to understand the details of headers just yet.
All will be explained. This header is primarily used so that you don't have
to understand every concept all at once.

Revised April 25, 2010: simple_error() added
*/

#ifndef H112
#define H112 201004L

#include<iostream>
#include<fstream>
#include<sstream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<list>
#include<vector>
#include<algorithm>
#include<stdexcept>

//------------------------------------------------------------------------------

#ifdef _MSC_VER
#include <hash_map>
using stdext::hash_map;
#else
#include <ext/hash_map>
using __gnu_cxx::hash_map;

namespace __gnu_cxx {

template<> struct hash<std::string>
{
size_t operator()(const std::string& s) const
{
return hash<char*>()(s.c_str());
}
};

} // of namespace __gnu_cxx
#endif

//------------------------------------------------------------------------------

#define unordered_map hash_map

//------------------------------------------------------------------------------

typedef long Unicode;

//------------------------------------------------------------------------------

using namespace std;

template<class T> string to_string(const T& t)
{
ostringstream os;
os << t;
return os.str();
}

struct Range_error : out_of_range { // enhanced vector range error reporting
int index;
Range_error(int i) :out_of_range("Range error: "+to_string(i)), index(i) { }
};


// trivially range-checked vector (no iterator checking):
template< class T> struct Vector : public std::vector<T> {
typedef typename std::vector<T>::size_type size_type;

Vector() { }
explicit Vector(size_type n) :std::vector<T>(n) {}
Vector(size_type n, const T& v) :std::vector<T>(n,v) {}
template <class I>
Vector(I first, I last) :std::vector<T>(first,last) {}

T& operator[](unsigned int i) // rather than return at(i);
{
if (i<0||this->size()<=i) throw Range_error(i);
return std::vector<T>::operator[](i);
}
const T& operator[](unsigned int i) const
{
if (i<0||this->size()<=i) throw Range_error(i);
return std::vector<T>::operator[](i);
}
};

// disgusting macro hack to get a range checked vector:
#define vector Vector

// trivially range-checked string (no iterator checking):
struct String : std::string {

String() { }
String(const char* p) :std::string(p) {}
String(const string& s) :std::string(s) {}
template<class S> String(S s) :std::string(s) {}
String(int sz, char val) :std::string(sz,val) {}
template<class Iter> String(Iter p1, Iter p2) : std::string(p1,p2) { }

char& operator[](unsigned int i) // rather than return at(i);
{
if (i<0||size()<=i) throw Range_error(i);
return std::string::operator[](i);
}

const char& operator[](unsigned int i) const
{
if (i<0||size()<=i) throw Range_error(i);
return std::string::operator[](i);
}
};

#ifndef _MSC_VER
namespace __gnu_cxx {

template<> struct hash<String>
{
size_t operator()(const String& s) const
{
return hash<std::string>()(s);
}
};

} // of namespace __gnu_cxx
#endif


struct Exit : runtime_error {
Exit(): runtime_error("Exit") {}
};

// error() simply disguises throws:
inline void error(const string& s)
{
throw runtime_error(s);
}

inline void error(const string& s, const string& s2)
{
error(s+s2);
}

inline void error(const string& s, int i)
{
ostringstream os;
os << s <<": " << i;
error(os.str());
}

#if _MSC_VER<1500
// disgusting macro hack to get a range checked string:
#define string String
// MS C++ 9.0 have a built-in assert for string range check
// and uses "std::string" in several places so that macro substitution fails
#endif

template<class T> char* as_bytes(T& i) // needed for binary I/O
{
void* addr = &i; // get the address of the first byte
// of memory used to store the object
return static_cast<char*>(addr); // treat that memory as bytes
}


inline void keep_window_open()
{
cin.clear();
cout << "Please enter a character to exit\n";
char ch;
cin >> ch;
return;
}

inline void keep_window_open(string s)
{
if (s=="") return;
cin.clear();
cin.ignore(120,'\n');
for (;;) {
cout << "Please enter " << s << " to exit\n";
string ss;
while (cin >> ss && ss!=s)
cout << "Please enter " << s << " to exit\n";
return;
}
}



// error function to be used (only) until error() is introduced in Chapter 5:
inline void simple_error(string s) // write ``error: s?? and exit program
{
cerr << "error: " << s << '\n';
keep_window_open(); // for some Windows environments
exit(1);
}

// make std::min() and std::max() accessible:
#undef min
#undef max

#include<iomanip>
inline ios_base& general(ios_base& b) // to augment fixed and scientific
{
b.setf(ios_base::fmtflags(0),ios_base::floatfield);
return b;
}

// run-time checked narrowing cast (type conversion):
template<class R, class A> R narrow_cast(const A& a)
{
R r = R(a);
if (A(r)!=a) error(string("info loss"));
return r;
}


inline int randint(int max) { return rand()%max; }

inline int randint(int min, int max) { return randint(max-min)+min; }

inline double sqrt(int x) { return sqrt(double(x)); } // to match C++0x

#endif


我把它与我的程序放在一个文件夹里编译运行时没问题,可是退出cfree时却总是出现内存不可read的错误不知是何缘故,用cfree的朋友请帮我测试下
baisoo 2010-09-27
  • 打赏
  • 举报
回复
路过,1:每天在论坛回复可以得10分;
dixiad 2010-09-27
  • 打赏
  • 举报
回复
我找到了这个文件,可是不知道把它放在哪,难道每建一个工程都加入这个文件?c free是去哪个目录找这类自定义头文件的?
源码直接下载地址: https://pan.quark.cn/s/854bd57df23a 在金融行业中,房产购置贷款是众多人在购置不动产时必须进行的一项财务规划。Matlab作为一种功能强大的数学及数据分析平台,经常被应用于各类复杂的运算,其中包括住房贷款的计算。本文将详细研究运用Matlab开发住房贷款计算程序的相关知识要点,以协助读者掌握如何借助编程技术处理实际的信贷问题。 1. **信贷种类** - **商业信贷**:此类贷款通常由金融机构提供,其利率会随市场行情变化,借款人可选用固定利率或浮动利率方案。 - **公积金信贷**:该类贷款获得政府机构的支持,利率一般低于商业信贷,但设有最高贷款金额的限制。 2. **偿付模式** - **等额本金偿付**:每月支付相同数量的本金,利息部分逐月减少,因此整体还款总额会逐步降低。 - **等额本息偿付**:每月支付固定金额的本金与利息组合,利息部分随本金的逐月减少而递减。 3. **住房贷款计算公式** - **等额本息偿付**:每月还款额=贷款本金×[月利率×(1+月利率)^(贷款期数)]÷[(1+月利率)^(贷款期数)-1]。 - **等额本金偿付**:每月应还本金=贷款总额/贷款期数,每月利息=(贷款余额-累计已还本金)×月利率。 4. **Matlab编程基础** - **变量设定**:在Matlab环境中,首要任务是设定贷款数额、年化利率、贷款时长等核心参数。 - **循环控制结构**:借助for循环来模拟每个还款周期的过程,进行本金与利息的计算。 - **函数构建**:将住房贷款的计算逻辑封装为函数,便于重复使用和测试不同条件下的结果。 5. **Matlab代码编写** - **等额本息函数实现**...

65,213

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧