Inheritance & Polymorphism

Inheritance Basics Today we will extend our use of objects, by investigating the idea of inheritance. Inheritance is the process by which a new class is created (derived) from another class, by inheriting the data and functions. Suppose we had a group of employees, but our employees were either salaried or hourly employees. In this …

Continue reading ‘Inheritance & Polymorphism’ »

Linked Lists

Remember structs from CP1? Consider this struct. struct ListNode { string item; int count; ListNode *link; }; typedef ListNode* ListNodePtr; Nothing new about joining a string and an integer data element into a single data element. The additional element is just a pointer to another struct of the same type and we now know about …

Continue reading ‘Linked Lists’ »

Week 9 – Templates

Introducing Templates Templates enable us to define functions and classes that have parameters for type names – essentially then we can use the same function (or object) for use with different types, making our programs much more flexible. Consider the following functions; void swap_values(int& variable1, int& variable2) { int temp; temp = variable1; variable1 = …

Continue reading ‘Week 9 – Templates’ »

Pointers & Dynamic Arrays

Preamble Consider what we know so far about variables. The computers memory is made up of lots of bytes – each byte has a number, or an address, associated to it. This picture might represent memory addresses 924 – 940. These memory addresses can then be used to store some data needed in our program; …

Continue reading ‘Pointers & Dynamic Arrays’ »

Week 4 – Namespaces

Week 4 – Namespaces This Weeks Topics Introducing Namespaces Creating Namespaces Declarations and Directives Unnamed Namespaces Introducing Namespaces Time to move back to C++ and look at a topic we skipped last semester, from chapter 9, section 2 of the course text – Namespaces. We’ve been using namespaces since week 1 of Computer Programming 1, …

Continue reading ‘Week 4 – Namespaces’ »

Week 2

Week 2 – Fundamentals Revisited This Weeks Topics Selection Statements Iteration Statements Exercise 1 Events for Form Controls Exercise 2 Selection Statements In Computer Programming 1, we encountered selection statements as a way of branching code to perform different tasks in different situations. C# logically is very similar in syntax to C++. The standard selection …

Continue reading ‘Week 2’ »

Week 1

Week 1 – Introduction to programming in C# This Weeks Topics Introducing C# Starting C# Console ‘Hello World’ Exercise 1 Extending C# Console Exercise 2 Introducing Windows Forms Code Window Form Design Window Exercise 3 Introducing C# C# is another member of microsoft’s .Net framework, along with C++, VB, J# etc. It is a very …

Continue reading ‘Week 1’ »