======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. * C++ is backwards compatible with C. * all the programs i have written in C can be compiled and run with C++ ====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. * compile with G++, save code with .cc * if your code isnt saved in the right format it wont compile with the right compiler. * public, privite ====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. * public and private * you cant access vars that are put in private if you are outside of the boundaries. * public and private ====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 * inheritance * its important to understand the relationship between the classes =====Keywords===== {{page>cprogpart2&nofooter}} =====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: * Was your hypothesis correct? Yes it was * Is there more going on than you originally thought? yes ===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: * Was your hypothesis correct? yes my hypothesis was correct ===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: * Do you feel the given resources are adequate in providing sufficient background information? * Are there additional resources you've found that you can add to the resources list? * Does the original experimenter appear to have obtained a necessary fundamental understanding of the concepts leading up to their stated experiment? * If you find a deviation in opinion, state why you think this might exist. ===Hypothesis=== State their experiment's hypothesis. Answer the following questions: * Do you feel their hypothesis is adequate in capturing the essence of what they're trying to discover? * What improvements could you make to their hypothesis, if any? ===Experiment=== Follow the steps given to recreate the original experiment. Answer the following questions: * Are the instructions correct in successfully achieving the results? * Is there room for improvement in the experiment instructions/description? What suggestions would you make? * Would you make any alterations to the structure of the experiment to yield better results? What, and why? ===Data=== Publish the data you have gained from your performing of the experiment here. ===Analysis=== Answer the following: * Does the data seem in-line with the published data from the original author? * Can you explain any deviations? * How about any sources of error? * Is the stated hypothesis adequate? ===Conclusions=== Answer the following: * What conclusions can you make based on performing the experiment? * Do you feel the experiment was adequate in obtaining a further understanding of a concept? * Does the original author appear to have gotten some value out of performing the experiment? * Any suggestions or observations that could improve this particular process (in general, or specifically you, or specifically for the original author).