• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/151

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

151 Cards in this Set

  • Front
  • Back
When dealing with input and output how is the variety of devices dealt iwht in most modern computers?
The input goes to device drivers and then access the library associated with them.
What, fundamentally does an istream do?
Turns character sequences into values of various types. Get those characters from "somewhere"
What, fundamentally does an ostream do?
Turns values of various types of character sequences. Sends those character "somewhere"
What, fundamentally is a file?
A sequence of bytes numbered from 0 upward.
What is a file formate?
A set of rules that determine what the bytes mean.
Name four different types of devices that can require I/O for a program.
GUIs, Keyboard, data itmes
What are the four steps for reading a file?
1. Know its name
2. OPen it
3. read in the characters
4. Close it
What are the four steps for writing a file?
1. Name it
2> Open it or create a new file
3. Write out our objects
4. Close it
Name and define the four stream states.
1. good() : The operations succeeded
2. eof() We hit end of input ("end of file").
3. fail() : Something unexpected happened.
4. bad() : Something unexpected and serious happened.
Discuss how the following input problems can be resolved:
a. The user typeing an out of range value
b. Getting no value (eof)
c. The user typing something of the wrong type.
a - c
handle the problem in the code doing the read
Why do we want to separate input and output from computation
To keep the code clean
What are the two most common uses of istream member function clear()?
ist.clear(iso_base::failbit); : set the state to fail
ist.clear(); :clear stream state
What are the usual function declarations for << and >> for a user defined type X?
data/types for output
data/types for input
Why is I/O tricky for a programmer?
iNPUT AND oUTPUT INVLOVES A LOT OF MESSY DETAILS DICATED BY HUMAN SENSIBILITIES TO WHAT TO READ AND ALSO PRACTICAL CONSTRAINTS ON THE USE OF FILES.
What does the notation <<hex do?
it takes the number from base 10 to the hexadecimal base (base 16)
What are hexadecimal numbers used for in computer science? Why?
Hexadecimal is popular for outputting hardware related information. A hexadecimal digit exactly represents a 4-bit value.
Name some of the options you may want to implement for formatting integer output.
<<general
<<hex
<<oct
<<showbase
<<noshowbase
<<fixed
<<scientific
<<general
What is a manipulator?
A piece of code that can change the inputted information to a different form in output
What is the prefix for decimal? For octal? for hexadecimal?
dec
oct
hex
What is the default output format for floating point values?
in decimal notation with as 2 places past the decimal (eg 1234.56) you inputted
What is a field?
A way to set up how much screen space is available for output. <<setw ( ) <<
Explain what setprecision() and setw() do.
setprecision() gives the amount of numbers past the decimal point to go to.
setw() sets the character spaces an output can fill
What is the purpose of file open modes
It allows the file to be opened for reading and open for writing. There are different modes that allow special circumstances to happen (binary, append, open at the end)
Which of the following manipulators does not stick: hex,scientific,setprecision,showbase,setw?
setw
What is the difference between chraacter I?O and binary I/O?
character I/O uses white space to end a number and uses the same number/letters in memory.
Binary also uses white space to end a variable, however it converts everything into binary.
Give an example of when it would probably be beneficial to use a binary file instead of a text file.
When you are using an image or a sound file.
Give two examples where a stringstream can be useful.
When you want to read a full line of text or when you wanted to read indiviual characters to see if all the information is correct.
What is a file position?
a position in the file that you can set to start reading/writing to/from.
What happens if you position a file position beyond the end of file?
It depends on the operating system as to what happens
When would you prefer line-oriented input to type-specific input.
When \n is not just whitespace or when you need a complete line including whitespaces.
What does isalnum(c) do?
It checks to see if c is a letter or a decimal digit.
Why do we use graphics?
They are useful, fun, provide lots of interesting code to read, they are good design examples, provide a good introduction to OOP.
When do we try not to use graphics?
When the data or calcuations can be shown better with text or not shown at all.
Why is graphics interesting for a programmer?
It allows us to do new things with our programs
What is a window?
A window is the canvas for the graphics to be placed on.
In which namespace do we keep our graphics interface (our graphics library)?
Graph.h
FLTK
What header files do you need to do basic graphics using our graphics library?
Point.h
Window.h
Simple_window.h
Graph.h
GUI.h
What is the simplest window to use
Simple_window
What is the minimal window?
The minmial window comes from Window.h, and it does not have a next button.
What's a window label?
A window label what you want to label the frame of the window.
How do you label a window?
Simple_window win(tl,600,400,"canvas");
gives the label as canvas
How do screen coordinates work? Window coordinates? Mathematical coordinates?
The screen has the top left as the origin and going left and down is positive. The top left of the window is the origin and going left and down is positive. Mathemicatl coordinates have the bottom left as the origin and up and left as positive.
What are exapmles of simple "shapes " that we can display?
Line
Lines
Polygon
Axis
Rectangle
Text
Image
What command attaches a shpae to a window?
win.attach(shape name);
Which basic shape would you sue to draw a hexagon?
polygon
How do you write teext somewhere in a window?
by using the text command
Text t(Point(150,150), "Hello,graphical world! ");
win.attach(t);
How would you put a photo of your best friend in a window (using a program you wrote yourself)?
Image ii(Point(100,50), "image.jpg");
win.attach(ii);
You made a Window object, but nothing appears on your screen. What are some possible reasons for that?
You didn't attach the window, you spelled it wrong, the points don't exist.
You have made a shape, but it doesn't appear in the window. What are some possible reasons for that?
You didn't attach the shape, you spelled it wrong, the points don't exist.
Why don't we "just" use a commercial or open-source graphics library directly?
There are too many options and it would be hard to teach everything that is needed.
About how many classes from our graphics interface do you need to do simple grahic output?
24
What are the header files needed to use the graphics interface library?
Point.h
Graph.h
Window.h
Simple_window.h
GUI.h
What classes define closed shapes?
Closed_polyline
Polygon
Rectangle
circle
Ellipse
Why don't we just use Line for every shape?
Some of the shapes don't use lines.
What do the arguments to Point indicate?
That Point is simply a pair of ints which act as coordinates
What are the components of Line_Style?
It is a class with an enumorated type insde of it.
What are the components of Color?
It is a class with an enumorated type insde of it.
What is RBG?
It is the classic color scale used to create colors from by using red,green,and blue mixed to create a color (range from 0-255 on each color)
What are the differences between two Lines and a Lines contatining two lines?
Two lines are two separate objects. A line containing two lines has two lines that are joined as one object.
What properties can you set for every Shape?
line style, line color, fill color, position, size
How many sides does a Closed_polyline defined by five Points Have?
5
What do you see if you define a Shape but don't attach it to a Window?
Nothing
How does a Rectangle differn from a Polygon with four Points?
A Rectangle has a semetrical height and width, it will always look like a box. A polygon with four points can look the same, but the points can also be make it look like something else.
How does a Polygon differ from a closed_polyline?
A polygon cannot intersect with itself
What's on top: Fill or outline?
outline
Why don't we bother defining a Triangle Class?
Because there are too many ways to do a triangle. A rectangle is always semetrical.
How do you move a Shape to another place in a Window?
name.move(x,y);
How do you labe a Shape with a line of etxt?
by placing the text on or nearby the shape
What properties can you set for a text string in Text?
the font, font size, color, bold or italic,bold and italic
What is a font and why do we care?
a font is a character font, a different way to have the text appear on the screen. It is important for style
What is Vector_ref for and how do we use it?
it holds unnamed objects. We use it the same way we would use a vector.
What is the difference between a Circle and an Ellipse?
An ellipse has a major and minor axis, instead of just a major axis
What happens if you try to display an image given a file name that doesn't refer to a file containing an image?
it will displace a bad image
How do you display part of an image?
by setting a mask
name.Set_mask(POINT(x,y)x.size,y.size);
What is application domain?
Application Domain is the how all of the classes and other objects work together from one particular perspective to emphasize what it can do and what it can't do.
What are ideals for naming?
different operations should have different names
What can we name?
Any object we create
What services does a Shape offer?
It allows the shape to move, have line systels, change color, and add points,
How does an abstract class differ from a class that is not abstract?
An abstract class is only abstract if it can be used only as a base class.
What is controlled by access control?
Access control controls the public, private, and proctected parts of a class.
What good can it do to make a data member private?
Any variables in private are only accessible from the class. Therefore it makes it impossible for the user to change the data directly in the program.
What is a virtual function and how does it differ from a non-virtual function?
a function or method whose behavior can be overridden within an inheriting class by a function with the same signature.
What is a base class?
a superclass or parent class is a class from which other classes are derived
What makes a class derived?
A class that is derived from a parent or base class to get information on functions.
What do we mean by object layout?
How objects are laid out in memory.
What is an inheritance diagram?
A diagram that shows how each class is dervied from each other.
What is the difference between a protected member and a private one?
A protected member can be used only be members of the class in which it is declared and members of classes derived from that. A private member can be used only by members of the class in which it is declared.
How does a pure virtual function differ from other virtual functions?
Classes with pure virtual functions tend to be pure interfaces. They tend to have no data members and no constructors.
Why would you make a member function virtual?
To give the generalizations of common characteristic of related entities to it. Then let that class be prospected so derived classes can use it.
Why would you make a virtual member function pure?
To give the generalizations of common characteristic of related entities to it. Then let that class be prospected so derived classes can use it.
What does overriding mean?
If a base class is declared as virtual and derived class is declared as virtual.This redefinition of virtual in derived class is known as Function overriding
What is object-oriented programming?
The use of inheritance, run-time polymorphism, and encapsulation in a program.
When would you use a continuous line to represent data? When do you use discrete points?
A continuous line would be used when the data occurs in a pattern over a period of time. Discrete points would be used to show points at specific instences
How do you make an x axis? A y axis?
Axis x(Asix::x,Point(x,y),xlength,notchspace, "name of axis)"

same for y except the axis is named y.
what is a default argument and when would you use one?
A default argument is an argument that is defined in your function. If the user doesn't input data for that argument, it will automatically use the default.
How do you add functions together?
by passing one function to another.
How do you color and label a graphed function?
the same way you would with any other object.
What do we mean when we say that a series approximates a function?
A series of terms can add up to a function to accurately reproduce the correct number without using the function.
Why would you sketch out the layout of a graph before writing the code to draw it?
To keep an idea of where things are in the window so we don't get lost and furstrated when the output doesn't come our correctly
How would you scale your graph so that the input will fit?
trial and error
How would you scale the input without trial and error?
by creating a class that can do it.

Scale(int,b int vb, double s) : cbase (b), vbase(vb), scale(s) {}
int operator()(int v) const {return cbase + (v-vbase)*scale);}
Why would you format your input rather than just having the file contain "the numbers"?
To create a function/class to read in the data and calculate it in a loop.
Why would you want a graphical user interface?
To allow the user to create their own input
When would you want a non-graphical user interface?
When you wanted control of the program.
What is a software layer?
A layer is where one part of the code is stored. The next level down is the deveried class and the level up is the base class.
Why would you want to layer software?
You would want to layer software to keep coding as simple as possible. The code would be passed from function to function until it was processed correctly.
What is the fundamental problem when communicating with an operating system from C++?
So of your code may get lost in the process. An error throw may not get back to C++ b/c the operating system may deal with it on it's own
What is a callback?
This is the function
that we want the GUI system to call when it detects a click on our window. Since
we give the function to the GUI for the GUI to "call back to us," it's commonly
called a callback function.
What is a widget?
A widget is an object in the GUI that allows us to define forms of interaction with the GUI through code.
What is another name for widget?
control.
What does the acronym FLTK mean?
fast light toolkit
How do you pronounce FLTK?
Full Tick
What are examples of widgets?
Buttons and menus, in and out boxes
When would you use an inbox?
When you want the user to input some text for the program to use.
What type of value is stored in an inbox?
a string or number
When would you use a button?
We would use a button for a pre defined action such as next or quit.
When would you use a menu?
A menu would be used when you have multiple buttons that are similar (e.g. Color menu -> blue,red,black,green)
What is control inversion?
It is when the user has control of the program instead of the programmer.
What is the basic strategy for debugging a GUI program?
Spimplifing the code and a systematic approach are the basic strategies.
Why is debugging a GUI program harder than debugging an "ordinary program using streams for I/O"
There are many things a user can do that you won't see.
Why do we need data structures with varying numbers of elements?
To be able to store information in one place efficiently.
What four kinds of storage do we have for a typical program?
Code, Static data, Free Store, Stack
What is free store? What other name is commonly used for it? What opperators support it?
The memory that is not used for code or static data. It is also called heap. It can use the "new" and "delete"
What is a dereference operator and why do we need one?
a dereference operator is a destructor (~) it deletes the operator and cleans up the memory.
What is an address? How are memory addresses manipulated in C++?
An address is where the bytes of the program are stored. Memory addresses can be manipulated with pointers or referenecs.
What information about a pointed-to object does a pointer have? What useful information does it lack?
It knows the type and location. It does not know how many elements it points to.
What can a pointer point to?
A pointer can point to nothing, a type, or array of the same type.
What is a leak?
A leak is memory that is not relseaed with the program is finished with it.
What is a resource?
The things that a function needs to function.
How can we initalize a pointer?
double* p2= new double(5.5);

by giving the pointer a new type WITH a value
What is a null pointer? When do we need to use one?
A null pointer is a pointer that has no value. use the null pointer when we have a pointer that sometimes
points to an object and sometimes not.
When do we need a pointer ( intsead of a reference or named object)?
You need a pointer when the onjects prefer pass by value and where functions can have no object.
What is a destructor? When do we want one?
A destructor releases the memory taken up by the object and deletes the object. We want one when there can't be any memory leak
When do we want a virtual destrutor?
When you have a vitural function.
How are destructors for members called?
delete[] p;
What is cast? When do we need to use one?
A cast refers to static_cast which convertes one type to another. We hardly ever need one because they are so dangerous to use.
How do we access a member of class through a pointer?
int* p= p[3];
What is a doubly linked list?
A list that has both a predecessor and a successor.
What is "this" and when do we need to use it?
IT is a pointer that points to the object for which the member function was called. We use ot ti refer to the whole object that we need to mention.
What is the default meaning of copying for class objects?
They copy the same location. Shallow copy.
When is the default meaning of copying of class objects appropriate? When is it inappropriate?
It is appropriate when we want the two to things being copied to be related. It is inappriate when we just want the same size.
What is a copy constructor?
A copy constructor is called whenever a new variable is created from an objec
What is a copy assignment?
The copy assignment operator lets you create a new object from an existing one by initialization
What is the difference between copy assignement and copy initialization?
A copy initialization is an initialization from an existing copy. A copy assignement is an initalization when copying.
What is shallow copy? What is deep copy?
A copy that only copies the pointer. A deep copy copies what the pointer points to.
What are the five "essential operations for a class?
Constructors from one or more arguments
Default constructor
Copy constructor
Copy assignment
Destructor
What is an explicit constructor? Where would you prefer one over the default alternative?
A constructor that only provides the usual construction semantics. You would want that when you don't want to copy the type.
What operations may be invoked implicity for a class object?
destructors and pointers
What is an array?
a series of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to a unique identifier
How do you copy an array?
Write a four loop that can use copy until the array is complete.
What is a C-Style string
zero terminated arrays of characters