Intro Classes - UAH CPE 212 Fundamentals of Software...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
UAH CPE 212 Fundamentals of Software Engineering Classes and Objects Class and Object Concepts Classroom Example Key Concepts
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
UAH CPE 212 This Time Two parts to programming Develop classes (user defined types) Use the classes (types) in a main program Problems with classes Learning the syntax Learning to use the class Learning to design classes Recall C style struct
Background image of page 2
UAH CPE 212 Class and Object Concepts Classes are things with common attributes Time dependent or independent attributes Implemented as Data Members Value of data members at a given time define the state of an object Member functions change the objects state By putting new values in the data members Examples of things with common attributes Clocks Keep time Set time Display time Cars Books Houses People
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
UAH CPE 212 Classroom Example What about this class? It is held in a classroom and there are students present. How could this represented? Classroom Students
Background image of page 4
UAH CPE 212 Classroom Example Part 2 Structure and syntax DECLARE then DEFINE DEFAULTS Header or Declaration file *.h #ifndef STUDENT_H_ //Start of guard block #define STUDENT_H_ #include whatever else needed to declare the type class Student //This is the name of the user defined type { public: //keywords to control access to inside of type //Need stuff to make type come into existence //Need stuf to make it go away cleanly //Need stuff to make it behave as if it were a built in type //THEN also need stuff to make it do whatever else you want it to do private: //Some of the stuff could be here }; #endif //End guard block The definition or *.cpp file #include “Student.h” Student::Student() { } and other member and non member functions
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
UAH CPE 212 Classroom Example Part 3 Declarations first and then definitions /******************************************************** TITLE: Student.h AUTHOR: Trog D. Lite PROJECT: Project -0 DUE DATE: now/now/now PURPOSE: This is the header for the student example *********************************************************/ #ifndef STUDENT_H_ #define STUDENT_H_ class Student { private: public: // Data Members char FirstName[20]; char LastName[20]; unsigned long Student_ID; // Constructors and Destructors Student(unsigned long ID = 0):Student_ID(ID){} // Operator overloads // Utility functions }; //End of Student #endif
Background image of page 6
UAH CPE 212 Classroom Example Part 4 How would this be used? #include <iostream.h>
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/09/2008 for the course CPE 212 taught by Professor Skipper during the Spring '07 term at University of Alabama in Huntsville.

Page1 / 18

Intro Classes - UAH CPE 212 Fundamentals of Software...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online