[LINUX] Programming Learned from Books May 9

Principles and practices of programming in C ++

https://amzn.to/2ytBG55

Chapter 19 vector, template, exception

--The vector implementation does not require, but do not prohibit, range checking in []. --As a general rule, when allocating a resource, it must be returned directly or indirectly to the part of the system that manages the resource. --As an example of resources, there is a memory lock file handle thread handle socket window. --Freestore memory allocated using the new operator and returned to the freestore using the delete operator --An object that is responsible for releasing a resource, such as a vector, is called the owner or handle of that resource. --Use vector instead of explicitly using the new or delete operators when the required storage interests in scope vary.

Chapter 19 drill

―― 1 define template struct S {T val;}; --2 Add a constructor so that it can be initialized using T --3 Define variables of type S S S S S <vector > and initialize them with the selected value ―― 4 Read and output those values ―― 5 Add a function template get () that returns a reference to val. ―― 6 Get the definition of get () out of the class --7 Make val private --8 Use get () to re-execute drill 4. --9 Add the function template set () so that val can be changed. --Replace 10 set () with S :: operator = (const T &). Hint much easier than 19.2.5 --11 Provide const version and non-const version of get () ――-12 Define the template read_val (T & v) function to read from cin to v --13 Read each value into the variable of drill 3 using read_val (), except for the variable of S <vector > type. ―― 14 Bonus, define the >> operator and << operator of vector Both operations use the {val, val, val} format. As a result, read_val () can also handle variables of type S <vector >.

Chapter 19 Exercises

--For each exercise, create two objects of the defined class and test them (using the output) to verify that the design and implementation actually work as expected. Where exceptions are involved, you need to think twice about where the error occurs.

--1 Write the template function f (). This function adds an element of type vector to another element of type vector . For example, f (v1, v2) executes v1 [i] + = v2 [i] for each element of v1.

--2 Write a template function that receives vector vt and vector vu as arguments. This function returns the sum of all vt [i] * vu [i]

--3 Describe the template class Pair. This class can store value pairs of any type. Use this class to implement a simple symbol table as used in the calculator program (7.8).

--4 Rewrite the Link class (17.9.3) and change it to a template that uses the value type as the template argument. Then use Link to re-execute Exercise 13 in Chapter 17.

―― 5 Define an Int class. This class contains only one class member of type int. Define constructors, assignments, operators +,-, *, /. Test this class and improve the design as needed, such as defining << and >> operators to make it easier to perform I / O.

Postscript

--By using a template, you can define a container such as vecotor separately from the element type definition. --By using an exception, the code that detects and notifies the error can be written separately from the code that handles the error. --You can use push_back () resize () reserve () to separate the definition of a vector from using that size.

Data Scientist Training Reader: Introduction to Machine Learning

https://amzn.to/3fvlfpr

Chapter 4 Forefront of Deep Learning

--The loss function is a function that returns how much the prediction output by the multi-layer perceptron is off.

Buddha's words

https://amzn.to/2A4nVdf ** Thinking about humans when studying artificial intelligence **

Chapter 3 Great Chapter

--People who are trapped in the pleasures of survival based on their desires are hard to liberate. Because it does n’t mean that others will let you go. -Do not consider yourself inferior or superior to others without showing yourself equal to others. --Do not rely on scholarship ――I have no wishes for this world or the afterlife

Recommended Posts

Programming Learned from Books May 8
Programming Learned from Books May 9
Programming learned from books May 11
Programming to learn from books May 10
Programming to learn from books May 7
Iptables learned from documentation
Deep Python learned from DEAP
This and that learned from boost.python