![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
THINKING IN C++
文章平均质量分 53
matrixdwy
这个作者很懒,什么都没留下…
展开
-
[THINKING IN C++]CHAPTER 03:EXERCISE 01
1. Creat a header file( with an extension of .h). In this file, declare a group of functions by varying the argument lists and return values from among the following: void, char, int, and float.原创 2008-05-17 23:15:00 · 752 阅读 · 0 评论 -
CHAPTER 05:EX 04
/*4. Write two classes, each of which has a member functionthat takes a pointer to an object of the other class. Createinstances of both objects in main( ) and call theaforementioned member function原创 2008-05-18 00:02:00 · 602 阅读 · 0 评论 -
CHAPTER 05:EX 05
/*5. Create three classes. The first class contains private data,and grants friendship to the entire second class and to amember function of the third class. In main( ),demonstrate that all of these原创 2008-05-18 00:03:00 · 567 阅读 · 0 评论 -
CHAPTER 10:EX 02
/*2. Create a function that returns the next value in aFibonacci sequence every time you call it. Add anargument that is a bool with a default value of false suchthat when you give the argument with原创 2008-05-18 00:13:00 · 519 阅读 · 2 评论 -
CHAPTER 10:EX 33
#ifndef MIRROR_H#define MIRROR_Hclass Mirror { Mirror *next; bool flag;public: Mirror():flag(true),next(0){} Mirror(Mirror *p) { next = p; flag = false;} bool test() { if (next原创 2008-05-18 00:16:00 · 438 阅读 · 0 评论 -
CHAPTER 10:EX 34
#ifndef MIRROR_H#define MIRROR_Hclass Mirror ...{ Mirror *next; bool flag;public: Mirror():flag(true),next(0)...{} Mirror(Mirror *p) ...{ next = p; flag = false;} bool test() ...{原创 2008-05-18 00:18:00 · 471 阅读 · 0 评论 -
CHAPTER 10:EX 24
#ifndef BOB_H#define BOB_Hnamespace bob{ class Widget { /* ... */ }; class Poppit { /* ... */ }; // ...}#endif //BOB_H/**//*24. Extract the namespace declarations inBobsSuperDuperLibrary原创 2008-05-18 00:22:00 · 466 阅读 · 0 评论 -
CHAPTER 10:EX 19
/*19. Modify FriendInjection.cpp to add a definition for thefriend function and to call the function inside main( ).*/#includeiostream>using namespace std;namespace Me { class Us原创 2008-05-18 00:23:00 · 397 阅读 · 0 评论 -
TICPP CHAPTER 11 EX 27 & EX28
/*27. Start with FunctionTable.cpp from Chapter 3. Create aclass that contains a vector of pointers to functions, withadd( ) and remove( ) member functions to add andremove pointers to funct原创 2008-05-23 22:50:00 · 678 阅读 · 0 评论 -
如何在DEV C++中编译ZThread。
在Thinking in C++ 第二卷中有一章节专门讲述并发,其中的例子需要ZThread,本文就介绍如何在DEV C++中编译ZThread库准备工作1.首先,你需要下载 ZThread-2.3.2。2.然后解压缩,这是一个tar文件,你可以用GNUWin32下的TAR解压缩,顺便一提,许多开源项目的压缩包都用到TAR和GZIP压缩格式,为了以后方便,你也可以下载一个GZIP:原创 2008-08-09 08:24:00 · 4132 阅读 · 0 评论 -
CHAPTER 04:EX 24
24. Create a struct that holds an int and a pointer to anotherinstance of the same struct. Write a function that takesthe address of one of these structs and an int indicatingthe length of the list yo原创 2008-05-17 23:58:00 · 663 阅读 · 0 评论 -
CHAPTER 03:EX 33
/*33. Declare a pointer to a function taking an int argumentand returning a pointer to a function that takes a charargument and returns a float.*/#includeiostream>using namespace std;void main () {原创 2008-05-17 23:40:00 · 427 阅读 · 0 评论 -
[THINKING IN C++]CHAPTER 03:EX 26
//26. Define an array of int. Take the starting address of that//array and use static_cast to convert it into an void*.//Write a function that takes a void*, a number (indicating//a number of bytes)原创 2008-05-17 23:33:00 · 607 阅读 · 0 评论 -
CHAPTER 04:EX 18
/*18. Write a function that takes a char* argument. Using new,dynamically allocate an array of char that is the size ofthe char array that’s passed to the function. Using arrayindexing, copy the cha原创 2008-05-17 23:53:00 · 589 阅读 · 0 评论 -
CHAPTER 04:EX 25
25. Repeat Exercise 24, but put the functions inside a structinstead of using “raw” structs and functions.#ifndef SOLUTION25_H#define SOLUTION25_Hstruct Link { int count; Link* next; vo原创 2008-05-18 00:00:00 · 491 阅读 · 0 评论 -
CHAPTER 07:EX 01
/**//*1.Create a Text class that contains a string object to hold the text of a file. Give it two constructors: a default constructor and a constructor that takes a string argument that is the name原创 2008-05-18 00:07:00 · 441 阅读 · 0 评论 -
关于指针引用
如果修改指针的指向,而非指针所指向的内存空间的内容?先看看下面这段代码void f1(int* ip) { ip = new int(10);}如果传入一个int* 指针,比如这样int* p;f1(p);实际上执行的是一个pass-by-value(传值)操作,p的指向没有发生改变。解决这个问题有2法:用指针的指针作为参数(a po原创 2008-05-18 15:31:00 · 634 阅读 · 0 评论 -
[THINKING IN C++]CHAPTER 04:EXERCISE 04
//:C03:Solution-04.cpp/*4. Modify Menu.cpp to use switch statements instead of ifstatements.*/#include iostream>using namespace std;int main() { char c; // To hold response bool flag=true; while(原创 2008-05-17 23:24:00 · 406 阅读 · 0 评论 -
CHAPTER 03:EX 27
/27. Create a const array of double and a volatile array of//double. Index through each array and use const_cast to//cast each element to non-const and non-volatile,//respectively, and assign a valu原创 2008-05-17 23:35:00 · 421 阅读 · 0 评论 -
[THINKING IN C++]CHAPTER 03:EXERCISE 03
//:C03:Solution-03.cpp/*3. Write a program that uses a while loop to read words from standard input (cin) into a string. This is an "infinite" while loop, which you break out of (and exit the pro原创 2008-05-17 23:22:00 · 427 阅读 · 0 评论 -
[THINKING IN C++]CHAPTER 03:EXERCISE 06
/* 6. Modify YourPets2.cpp so that it uses various differentdata types (char, int, float, double, and their variants).Run the program and create a map of the resultingmemory layout. If you have acce原创 2008-05-17 23:27:00 · 467 阅读 · 0 评论 -
[THINKING IN C++]CHAPTER 03:EXERCISE 07
/* 7. Create two functions, one that takes a string* and onethat takes a string&. Each of these functions shouldmodify the outside string object in its own unique way.In main( ), create and initiali原创 2008-05-17 23:29:00 · 537 阅读 · 0 评论 -
C++编程思想 第二卷 勘误
注:这是我本人在看C++编程思想 第二卷:实用编程技术(刁成嘉译)时发现的翻译问题。特此列一表,供各位参考及讨论 。本人收集的翻译不妥之处大部分为那些狗屁不通之句,影响读者理解之句以及误人子弟之句。关于名词翻译的修改较少,希望能够给各位软件初学者以一定帮助。若本人勘误有错,欢迎指正。 勘误连接 第一章 异常处理原创 2008-06-17 21:34:00 · 2682 阅读 · 6 评论