User Tools

Site Tools


opus:fall2012:rthatch2:part1

Part 1

Entries

Entry 1: August 30, 2012

This week was my first back in school in a little while and I am enjoying it. in data structures we started talking about pointers and writing small programs to test pointers and get familiar with them. in discrete structures we started on logic and started writing programs to implement the different boolean logic i picked converse non implication. Also in both classes we have been brushing up on / reviewing C which is never a bad thing the only challenges so far i feel I'm facing is the logic gate I guess also the size program in data where we had to test the size limits of the various data types but that is a good challenge and its always fun to try and solve problems and see peoples different approaches to the same problem.

Entry 2: September 15, 2012

This week we started working on linked lists and doubly linked list we wrote a linked list together than on our own we implemented differernt functions like append, insert, and remove we also started a doubly linked list and are going to be implementing the different functions for that as well. in discrete we refined our logic programs and started working on sets i choose to use a linked list to write my set program all in all good week plenty of things to keep me busy I also finished my keywords for discrete and data

Entry 3: Septembr 22, 2012

This week we got our other random keywords that we need to work on and show an example of we worked more on linked lists which i am getting better at thier still a little tuff to just do without writting it out and tweaking logic we are also working on the doubly linked list more which is always fun but other than that we havent started on anything new yet we talked today about whats coming next stacks and queues. and are just finishing up doubly linked list

Entry 4: September 30, 2012

This week I finished my opus part 1 and finished my other keywords and experiment my experiment wasn't to special but I couldn't think of any others to do. In class we started writing a sort program to sort data and finished all the modifications on our singly linked list. next week as I understand it we will begin on doubly linked list insert and remove and work on our sort program so far so good happy about completing the first part of my opus

Keywords

data Keyword 1

Function Pointers

Definition

Function Pointers are pointers that point to the memory location of a function and can be used to call and pass arguments to said function. This can be used when you might have a few functions and only one of them needs to be called but at the time of writing the program you don't know which one needs to be called.

References

Class Pointer [C++], Data Phase 2

Definition

Holds the address of another variable.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

  • Reference 1
  • Reference 2
  • Reference 3

Demonstration

Demonstration of the indicated 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:

/*
 * Declaring and using a class pointer
 */
#include <iostream>
#include "class.h"
 
using namespace std;
 
int main()
{
   class variable;
   class *classPointer = &variable;
 
   int localVariable;
 
   classPointer->classSetFunction(localVariable);
 
   return(0);
}

discrete Keyword 1

Converse Nonimplication

Definition

Converse Non-implication is the negation of the reverse of implication. implication is if … then where it is only false if the first term “p” is true and the second term “q” is false so converse non-implication is only true if the first term “p” is false and the second term “q” is true

References

Discrete keyword 1 Phase 2

exclusive disjunction/nonequivalence

Definition

Exclusive disjunction means that only one can be true, but not both. It's basically an XOR.

References

Demonstration

Demonstration of the indicated 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:

/*
 * Exclusive Disjunction
 */
#include <stdio.h>
 
int main()
{
    int p;
    int q;
    int r;
 
    printf("Enter a 1 or a 0 to xor:\n");
    scanf("%d", &p);
 
    printf("Enter a second 1 or 0:\n");
    scanf("%d", &q);
 
    r=p^q;
 
    printf("The xor of the values you've entered is: %d",r);
 
 
 
 
    return(0);
}

Experiment 1

Question

Can I pass a class pointer by reference?

Resources

Hypothesis

I feel a class pointer can be passed by reference just like a normal pointer

Experiment

I am going to write a program and pass a pointer by reference.

Data

  1 #include <iostream>
  2 
  3 
  4 Class A
  5 {
  6         public:
  7         A();
  8         function(int **pointer)
  9 
 10         private:
 11         int variable;
 12         int filler;
 13 };
 14 
 15 void A::functionint(int **points)
 16 {
 17         int *points;
 18 }
  1 #include <iostream>
  2 #include "class.h"
  3 
  4 using namespace std;
  5 
  6 int main()
  7 {
  8         class classVariable;
  9         class *classPointer = &classVariable;
 10 
 11         int variable1;
 12 
 13         function(&classPointer);
 14 
 15 return 0;
 16 }

Analysis

Based on the data collected:

  • My hypothesis was correct?
  • I had to pass the pointer to another pointer to pass by reference
  • the only shortcoming in the data is a small simple class was created just for the purpose of passing a pointer the experiment could have been done in a larger program and not a controlled environment

Conclusions

Ive discovered that class pointers can be passed by reference the same as a local pointer.

opus/fall2012/rthatch2/part1.txt · Last modified: 2012/10/01 01:34 by rthatch2