Table of Contents

Part 2

Entries

Entry 5: 3/6/2012

Today in C/C++ we started to look at stuff in C++ for the first time. I learned that C++ is backwards compatible with C. I also learned that C++ is a object oriented programming language, and can be more easily managed.

Entry 6: 3/8/2012

Today in C/C++ we took a look more at C++, i learned that you save your files with .cc rather than .c. Also i learned that you compile your code with G++ rather than with gcc.

Entry 7: 3/13/2012

Today in C/C++ we looked more at concept in C++, we spent some more time with public and private concepts. I learned that you can access things that are private by using a var that is public that can access the private vars.

Entry 8: 3/15/2012

We have been looking more at C++ code, and we have been learning some concepts such as inheritance. I have learned that child classes can inherit things from parent classes

Keywords

cprog Keywords

(compiler)

compiler

Definition

a computer program that takes a file written in source code and changes it into a different computer language to run the program.

Demonstration

Demonstration of the chosen keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

gcc -o file file.c

(Preprocessor)

Preprocessor

Definition

a program that processes source code before its gets compiled.

Demonstration

(Assembler)

Assembler

Definition

a program that changes assembly language into computer language.

(Return Types)

Return Types

Definition

a function that needs to be put at the end of a method, that tells the computer what to return.

Demonstration

Demonstration of the chosen keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

#include <stdio.h>
 
int main()
{
    return(0);
}

(inheritance)

inheritance

Definition

a way to re-use code, from higher up classes

(public class)

public class

Definition

a class in C++ programming that all entities can access.

(private class)

private class

Definition

a class in C++ programming that only variable in defined in the private class can access, unless a pointer is used.

(multi-file program)

multi-file program

Definition

a program that is broke up into multiple header and .cc files, that are all brought together in main.cc

cprog Objective

cprog Objective

-write and compile code that utilizes programming constructs -use pointers and variables to discover the indirect properties of data storage -comprehend the basics of memory management, data representation and storage -identify and label various data types as scalar vs. composite -distinguish and explain difference between homogeneous and heterogeneous composite data types -break down and separate code into functions and illustrate the use of parameter passing -justify the use of various programming constructs within code solutions -discover the standard libraries and use libraries in solving problems

Definition

students should be able to -Write programs -use pointers effectively -understand what memory management is. -use the different data types -use the different libraries to do what your trying to do

Method

I will be measuring my success in this class on whether or not i will be able to complete the projects.

Measurement

According to my method, i am understanding the basics of what i need to do, but when it comes to putting it all together in a programs by my self, i am only able to do about have of it. I end up needing to get assistance from Matt or class mates.

Analysis

Reflect upon your results of the measurement to ascertain your achievement of the particular course objective.

  • i am doing pretty good
  • there is definitively room for improvement
  • i think my method is a pretty good way to measure success

Experiments

Experiment 4

Question

What would happen if i changed the “” around the printf statement in the Hello World program to ''?

Resources

From some resources on Wikipedia, if i were to run the program with single quotes instead of double quotes it would segfault

Hypothesis

I think that the program will have some warnings compiling the code (do not know what problems in specific) and will have a segmentation fault when i go to run it.

Experiment

To test this i am going to replace printf(“Hello, World!\n”) with printf('Hello, World!\n'). compile and run

Data

When i change out the quotations, the compiler says “ warning: character constant too long for its type hello.c: In function 'main': hello.c:3: warning: passing argument 1 of 'printf' makes pointer from integer without a cast /usr/include/stdio.h:339: note: expected 'const char * restrict' but argument is of type 'int'”. And then it seg faults when i run it.

Analysis

Based on the data collected:

Conclusions

I have concluded that one little syntax error can totally change what the program thinks you want to do.

Experiment 5

Question

Can i use both printf and cout statements within the same code?

Resources

c++ pocket reference

Hypothesis

Based on what i have been reading in the C++ pocket reference, most c code can be used in a c++ program, compiled with G++. My hypothesis is that i can use both printf and cout statements in the same code provide it is compiled as C++.

Experiment

I am going to write a program in C++ and compile it in C++ and use both a printf and cout statement.

Data

The program compiled fine and ran fine with mixing both printf and cout statements.

Analysis

Based on the data collected:

Conclusions

I can conclude that C++ is backwards compatible with C provided u include the correct header files.

Retest 2

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: