C++primer4——chapter12

#include<iostream>

#include<vector>
using namespace std;

/*
class Sales_item
{
public:
	double avg_price()const;
	bool same_isbn(const Sales_item &rhs) const
	{ return isbn == rhs.isbn; }
	Sales_item(): units_sold(0), revenue(0.0) { }//构造函数
private:
	string isbn;
	unsigned units_sold;
	double revenue;
};

double Sales_item::avg_price()const
{
	if(units_sold)
		return revenue/units_sold;
	else
		return 0;
}
*/

/*
class Screen
{
public:
	typedef std::string::size_type index;
	index func(int a.int b);
private:
	index heghit,wight;
	std::string contents;
	std::string::size_type cursor;
	//std::string::size_type heghit,wight;
protected:
};

inline Screen::index Screen::func(Screen::index a,Screen::index b)
{
	return a+b;
}
*/

/*
class Screen {
public:
	// interface member functions
	Screen& move(index r, index c);
	Screen& set(char);
	Screen& set(index, index, char);
	Screen& display(iostream &os)
	{
		do_display(os);
		return *this;
	}
	// other members as before
private:
	Screen& do_display(iostream &os)const
	{
		//do something displsy
		os<<"what is the func!!"<<endl;
	}
};
*/

/*
int hight;
class aa
{
public:
	int diaoyong(int hight)
	{
		return hight;
	}

	int diaoyong1(aa::hight)
	{
		return hight;
	}
	int diaoyong2(::hight)
	{
		return hight;
	}
private:
	int hight,with;
protected:

};
*/

//构造函数
/*
class sales_item
{
public:
	//sales_item():b(2){}
	explicit sales_item(int& c ):b(c){}
	explicit sales_item(istream& ist);

	void m_cout()
	{
		cout<<this->b<<endl;
	}
private:
	int b;
	std::string a;
	int revenue;
};
sales_item::sales_item(istream& ist)
{
	ist>>b;
}
*/

//友元,friend
/*
class screen
{
	friend class win_con;
public:
protected:
private:
	int a;
	string b;
	char c;
};
class win_con
{
public:
	win_con& control(screen &s);

};
win_con& win_con::control(screen &s){
	s.a+=1;
	return *this;
}
*/

//static

int main()
{
	//vector<int> a;
	//sales_item my_sales(cin);
	//int x=5;
	//sales_item my_sales(x);
	//my_sales.m_cout();
	system("pause");
	return 1;

}

  

时间: 2024-07-30 15:57:52

C++primer4——chapter12的相关文章

c++primer4 Chapter2变量和基本类型2.4、2.5、2.6

2.4 const限定符 const对象默认为文件的局部变量,此变量只存在于那个文件中,不能被其他文件访问.通过指定const变量为extern,就可以在整个程序中访问const对象. Exercise2.22 设置一个const变量代替循环上界100 Exercise2.23 第一个不合法,const变量必须初始化. 第二个合法.第三个不合法,改变了const变量的值. 2.5 引用 非const引用只能绑定到与该引用同类型的对象,const引用则可以绑定到不同但相关的类型的对象或绑定到右值.

c++primer4 Chapter2变量和基本类型2.3

2.3 变量 Exercise2.11 #include <iostream>using namespace std;int main(){ cout<<"Enter base and exponent:"; int base,exp; cin>>base>>exp; int result=1; for (int cnc=0;cnc!=exp;++cnc) result*=base; cout<<base<<&qu

面向对象chapter12

使用jdbc步骤 a.导入数据库厂商提供的驱动程序(导入jar包) b.加载驱动程序 Class.forName("驱动程序类"); c.获得连接 Connection conn =DriverManager.getConnection(url,username,password); url = "jdbc:数据库://ip地址:端口;数据库"; username="用户名"; password="密码"; d.获得执行sql

Java1:Chapter12

第十二章 无参和有参 无参方法 public 返回值 方法名(){ //方法体 } 注意: 如果没有返回值,那么返回值类型是void. 如果有返回值,那么必须用return 返回值,并且该值的数据类型必须是定义方法 时的数据类型. return的作用: a.返回值 b.结束方法.(与break类似) 2.写方法时注意 第一点:定义void为返回值类型时,不能使用return+返回值. 第二点:方法不能返回多个值. 第三点:方法不能嵌套. 第四点:不能在方法外部直接写程序逻辑代码. 有参方法 1.

Chapter12 Scala操作符

1. 标识符 变量名.函数名.类名等统称为标识符,scala可以使用任何字符来作标识符,比如 ()!#%&×+-/:<>[email protected]\^|~ 等. 反引号中可以使用任何字符序列. val √ = scala.math.sqrt _ √(2) val `val` = 42 println(`val`) 2. 中置操作符 操作符要接两个参数,分别位于操作符两边. a 标识符 b 等价于 a.标识符(b) . 1 to 10 等价于 1.to(10) 1 -> 1

【APUE】Chapter12 补充

补充记录12.8 Threads and Signals 以及 12.9 Threads and fork两部分 只有两个小节,但是断断续续看了几次,争取用不同的例子尽量多理解这两部分内容. 有理解的不深刻,不正确的地方,以后再求改正. 12.8 Threads and Signals 作者提醒大家,“信号+进程”本身就已经比较复杂了,如果再跟多线程搅和在一起就更加作死了. 有几个基本的outline: (1)每个线程都有各自的signal mask(可以设定当前线程屏蔽哪些信号) (2)但是s

龙书9 chapter12 viewMatrix的推导和camera的基本功能实现

本章主要是推导viewMatrix和设计一个基本的camera功能 笔记一.viewMatrix的推导 关键语句: 1.在world坐标系中的物体怎么在camera坐标系中描述,等价于world坐标系中的物体和camera一起变换,使camera坐标系和world坐标系重合. 2.标准正交矩阵的逆和转置等价 已知参数:camera的position,三个朝向向量 推导过程:1.平移到原点 2,进行旋转变换 还有个Matrix没有推导,就是 点p绕任意轴旋转的matrix.... 笔记二: cam

c++primer4 Chapter2变量和基本类型2.2

2.2 字面值常量 Exercise2.7 (a)'a'是char型字面值,L'a'是wchar_t型字面值,"a"是字符串字面值,L"a"是宽字符串字面值. (b)10是int型字面值,10u是unsigned型字面值,10L是long型字面值,10uL是unsigned long型字面值,012是八进制表示的int型字面值,0xC是十六进制表示的int型字面值. (c)3.14是double型字面值,3.14f是float型字面值,3.14L是long doub

c++primer4 Chapter2变量和基本类型2.1

2.1基本内置类型 算术类型: 最小存储空间 bool 布尔型 char 字符型    8位 wchar_t 宽字符型 16位 short 短整型   16位 int   整型        16位 long 长整型    32位 float 单精度浮点型 6位有效数字 double 双精度浮点型 10位有效数字 long double 扩展精度浮点型 10位有效数字 void类型:用作无返回值函数的返回类型 2.11 整型 表示整数.字符和布尔值的算术类型合称为整型. 带符号的整型signed