Table of Contents

Part 3

Entries

Entry 9: April 22, 2012

Wow, its been a long time since I have posted anything. Still working on the projects required for my C/C++ class. Its getting down towards the end of the semester, only 2 weeks left. I am swamped from all my other classes. I wanted to do much better then I have on this opus but have found it incredibly difficult to keep up with between juggling my other classes, work, and life in general. I just hope I have learned enough to pass the class. I have to admit, this class has been a struggle. It seemed pretty easy starting out, but as things progressed I started finding the course difficult to grasp. I'm still having a hard time with the concept of modules and classes which is why project 3 has yet to be completed. I just hope the instructor has some mercy when it comes to grading because I have tried my hardest and stuck it out the entire semester not missing a single class. Well I guess that's all for right now. Back to work on other matters at hand.

Entry 10: April 26, 2012

Not much has changed. Still working away on getting project 3 done. I am getting closer to the end of it but still have to figure out the exponent and modulus functions. The exponent function so far has been giving me problems and I think it due to the way my multiplication and addition functions are written. Hopefully I can get this finished up soon so I can start on project 4. Well that all for now. I will post again once I have made progress on my current project.

Entry 11: May 1, 2012

Well I have figured out that the problems I was having with project 3 were indeed due to the way the multiplication and addition functions were written. I am now in the process of writing an entirely new exponent module from scratch and abandoning the possibility of calling the other 2 functions from within the exponent function. I have also been reading up on the pow function what will do what I want but it has its drawbacks. The major one is the fact that pow relies on integer data to perform its operation. I will keep working on it and only use pow as a last ditch effort to get the function working. Well back to work, the end is drawing near and I still have a ton of work to do.

Entry 12: May 3, 2012

Well its the last official day of class, next week is finals week and then its all over. I can end the week on a good note. I now have functioning exponent and modulus functions in my project 3. I ended up using pow for the exponent function which was not the best thing but at least it works. The modulus function on the other hand does utilize previously created functions and does work as expected so modulus does not have the limitations that exponent does. I wish I had the time to do all the experiments that were wanted for the C/C++ class but I put forth so much time and effort on the projects for this class and my other classes that I just never had the time to do them. I have to sit back though and think that all the trial and error that I went through to complete the projects would make up for the experiments that were not done because this class as a whole is based on experimentation. I had to experiment with many different things to figure out what worked and what didn't and the results of those experiments are the projects that were produced. Well I guess that is it, now to work on the end of course experience and hopefully graduate in a couple of weeks. Its been a long and challenging path but it has been a rewarding one and I can safely say that I can come away from this semester with knowledge that I didn't have when it all started. If time permits I will hopefully make one more post when everything is done and I can finally sit back and breath a sigh of relief.

cprog Keywords

Compiler, Preprocessor, Flags, Assembler, Linker, Milti-file Programs
Definition

Compiler - A compiler is a program that can assemble a human readable source code into machine code that a system can execute.

PreProcessor - A preprocessor is a program that performs some sort of preliminary processing on an input before being processed by the main program.

Flags - A flag is a variable or memory location that stores a true-or-false value, normally either recording the fact that an event had occured or a request for a certain action to take place.

Assembler - An assembler is a program that is used to convert instructions written in a low level code into maching code.

Linker - A computer program that adjusts two or more machine language program segiments so they can be loaded simultaneously and executed as one unit.

Multi-file Programs - Multi-file programs are programs that have been broken up into easier to manage blocks of code. Normally functions have there own file and each function has its own header file. This is done to keep code modular and organized. Keeping code modular like this allows for code to be reused elsewhere.

Demonstration

Below is a link to a Mulit-file program I have created. Once you click on the link simply scroll down to the code section of the page. Note how all the functions have there own seperate file.

http://www/user/brobbin4/portfolio/cprogproject3

I/O Streams
Definition

I/O streams are channels in which data can flow to or from any I/O device. I/O device is a device such as a keyboard, mouse, disk drive, basically anything that can either send input to a system or recieve output from a system.

In C++ an I/O stream can be refered to any data stream that sends data into a program or recieves data from a program.

C++ does not have I/O streams built into the language and instead use the iostream library to provide the necessary information to handel I/O streams. C++ has some basic I/O streams available to it which are cin, cout, cerr.

cin - the C++ standard input cout - the C++ standard output cerr - the C++ standard error handler. This is used when a program ancounters an error and needs a place to send that error information.

Stream operators can be defined as an operator that has an influence on how the data from I/O Streams are handeled.

Type Casting Operators, Const-Volatility Specifiers
Definition

Type casting operators are operators that are used to change one data type to another data type. The most general cast operator supported by most C++ compilers is “(type) expression” where type is the desired data type.

Const short for constant means something is not modifiable, so data objects that are declared with const as a part their type specifications must not be assigned to in any way during execution of a program. Most of the time the definitions of the objects will contain an initializer because you cannot assign it and if they didn't contain an initializer you would never get a value.

Volatile means something can me modified and we have this type specifier mainly for problems that are encountered in real-time or embedded systems programming using C++. For example you are creating code that will control a hardware device by placing values in hardware registers at known absolute addresses. Because this is happening in real time we need a way to change these values on the fly but most C compilers have not been able to handle this in the past. To correct this issue and other issues that have to do with when to write to where a pointer points the volatile keyword was introduced. This tells a compiler that an object is subject to sudden change for reasons which cannot be predicted from a study of the program itself and this forces every reference to such objects to be a genuine references.

Classes
Definition

A class is an expanded concept of a data structure. A class is the definition of an object and thus a class can hold not only data but it can hold functions too. Classes resemble structs with one difference, all struct members are public by default where all class members are all private by default.

Objects - objects are components of a program that know how to perform certain actions. Objects also know how to interact with others pieces of a program.

Constructor - A constructor is a member function with the same name as its class. Constructors are called as such because they construct the values of data members of the class. A constructor resembles an instants method but differs from a method because a constructor never has an explicit return type.

Destructor - A destructor is like a constructor is the fact that it is a member function with the same name as its class and that it resembles ans instants method but never has an explicit return value. A destructor is used to deallocate memory and do other cleanup tasks for a class object and its class members when an object is destroyed.

Access Control - C++ employs access control to limit access to certain data within a class. below are the ways that this is accomplished.

Public - members specified within the public section of a class are accessible from any function.

Protected - members specified within the protected section of a class are accessible only by the functions of the class that original declared the members, friends of the class that originally declared the members, classes derived with public or protected access from the class that originally declared the members, and direct privately derived classes that also have private access to protected members.

Private - members specified within the private section of a class are accessible only from member functions and friends of the class.

Friend - A friend allows a function or class to gain access to to the private and protected members of a class in which they are not a member of.

“This” Pointer - “this” pointer is a pointer that is accessible only within the non-static member functions of a class, struct, or union. It points to the member function for which the member function is called.

Inheritance
Definition

Inheritance is the mechanism of reusing and extending existing classes without modifying them. Inheritance is kinda like embedding an object into a class. For example, you declare object c of class M in the class definition of R. The result is class R will have access to the public data members and member functions of class M, however in class R you will have to access the data members and member functions of class M through object c. In single inheritance classes have only one base class while in multiple inheritance classes may have multiple base classes.

Polymorphism/Virtual Functions - A key feature of derived classes is that a pointer to a derived class is type-compatible with a pointer to its base class. Polymorphism means that a call to a member function will cause a different function to be executed dependent on the type of object that invokes the function. A virtual function is a function in a base class that is declared using the keyword virtual.

Abstract Base Class - An abstract base class is a base class that contains at least one pure virtual function. A pure virtual function is declared by using a pure specifier in the declaration of a virtual member function in the class declaration.

Overloading
Definition

Overloading is the practice of supplying two or more definitions for a given function name in the same scope. The compiler is left to pick the appropriate version of the function or operator based on the arguments with which it is called.

Functions - Function overloading is the act of declaring more then one function with the same function name in the same scope. The declarations of each function must differ from each other by the types and/or the number of arguments in the argument list. When an overloaded function is called the the correct function is selected through comparison of the argument list of the of the function call with the parameter list of each of the overloaded candidate functions with the same name.

Operators - The operator keyword declares a function specifying what operator-symbol means when applied to instances of a class. This gives the operator more than one meaning, or “overloads” it. The compiler distinguishes between the different meanings of an operator by examining the types of its operands.

Exception Handing
Definition

Exceptions are run-time anomalies, such as divide by zero, that require immediate handling when encountered. The C++ language provides built-in support for raising and handling exceptions. With C++ exception handling, a program can communicate unexpected events to a higher execution context that is better able to recover from such abnormal events. These exceptions are handled by code that is outside the normal flow of control.

Throw, Try, Catch - these three keyword are the basis of error handling in the C++ language and are defined below.

Throw - A program throws an exception when a problem shows up. This is done using a throw keyword.

Try - A try block identifies a block of code for which particular exceptions will be activated. It's followed by one or more catch blocks.

Catch - A program catches an exception with an exception handler at the place in a program where you want to handle the problem. The catch keyword indicates the catching of an exception.

Templates, STL
Definition

Templates are mechanisms for generating functions and classes based on type parameters. Through the use of templates, you can design a single class or function that operates on data of many types, instead of having to create a separate class for each type.

STL - The STL or Standard Template Library is a collection of C++ libraries that allow the use of several well known kinds of data structures without having to program them. The templates are designed to efficiently run code. The compiler does most of the work of generating the efficient implementations of the templates.

cprog Objective

Experiments

Experiment 7

Question

What is the question you'd like to pose for experimentation? State it here.

Resources

Collect information and resources (such as URLs of web resources), and comment on knowledge obtained that you think will provide useful background information to aid in performing the experiment.

Hypothesis

Based on what you've read with respect to your original posed question, what do you think will be the result of your experiment (ie an educated guess based on the facts known). This is done before actually performing the experiment.

State your rationale.

Experiment

How are you going to test your hypothesis? What is the structure of your experiment?

Data

Perform your experiment, and collect/document the results here.

Analysis

Based on the data collected:

Conclusions

What can you ascertain based on the experiment performed and data collected? Document your findings here; make a statement as to any discoveries you've made.

Experiment 8

Question

What is the question you'd like to pose for experimentation? State it here.

Resources

Collect information and resources (such as URLs of web resources), and comment on knowledge obtained that you think will provide useful background information to aid in performing the experiment.

Hypothesis

Based on what you've read with respect to your original posed question, what do you think will be the result of your experiment (ie an educated guess based on the facts known). This is done before actually performing the experiment.

State your rationale.

Experiment

How are you going to test your hypothesis? What is the structure of your experiment?

Data

Perform your experiment, and collect/document the results here.

Analysis

Based on the data collected:

Conclusions

What can you ascertain based on the experiment performed and data collected? Document your findings here; make a statement as to any discoveries you've made.

Retest 3

Perform the following steps:

State Experiment

Whose existing experiment are you going to retest? Provide the URL, note the author, and restate their question.

Resources

Evaluate their resources and commentary. Answer the following questions:

Hypothesis

State their experiment's hypothesis. Answer the following questions:

Experiment

Follow the steps given to recreate the original experiment. Answer the following questions:

Data

Publish the data you have gained from your performing of the experiment here.

Analysis

Answer the following:

Conclusions

Answer the following: