L16classes

L16classes - what is an aggregate construct? What aggregate...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: what is an aggregate construct? What aggregate constructs have we studied? whats a structure? whats the keyword to define a structure? what are structures used for? is a structure definition an executable statement? Can it be put in a header file? why include ing a header file with structures definition multiple times is a problem? how is this problem solved? what are #define #ifndef #endif ? what is a structure variable? how are elements of a structure called? do elements of the same structure (different structures) have to have unique names? how can structures be initialized? what happens when one structure variable is assigned the value of another? can structures be passed as parameters? by value? by reference? can a function return a structure? Structures Revisited Classes Structure is an aggregate construct providing encapsulation encapsulation - combining a number of items in a single entity consider implementing date: as structure: struct Date{ int month; int day; int year; }; and a set of functions manipulating dates: void set_date(Date &d, int, int, int); void add_year(Date &d, int n); bool compare(Date &d1, Date &d2); problems: there is no explicit connection between data type (structure) and these functions it does not specify that the functions listed should be the only ones that access and modify date variables if there is a bug in Date manipulation - it can be anywhere in the program if modification of Date is needed - all program needs to be updated Whats Wrong with Structures?...
View Full Document

This note was uploaded on 04/22/2010 for the course CS 23021 taught by Professor Staff during the Spring '08 term at Kent State.

Page1 / 10

L16classes - what is an aggregate construct? What aggregate...

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

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