These are called objects in C++.
string variable;Sets variable to the empty string.
string variable = "initial value";
my_name . length()
my_name . substr(0,1)
. . . . . . . . . ( end of section 2.6 Strings) <<Contents | End>>
|String member functions||Returns|
Employer("Richard Botting", 80000)
Employer me ("Richard Botting", 80000)
|Time()||constructor||Makes an object for the current time|
|Time(h,m,s)||constructor||Makes the time with hours h, minutes m, and seconds s|
|t.get_seconds()||accessor||return number of seconds in t|
|t.get_minutes()||accessor||return number of minutes in t|
|t.get_hours()||accessor||return number of hours in t|
|t.add_seconds(n)||mutator||changes t to n seconds later|
|t.seconds_from(t2)||accessor||return the number of seconds between t and t2|
|Employee(n,s)||constructor||makes a new employee with name n and salary s|
|e.get_name()||accessor||returns the name of e.|
|e.get_salary()||accessor||returns the salary of e.|
|e.set_salary(s)||mutators||changes the salary of e|
/share/ccc3ewe also have to include the windowing library called "X11R6" in our code. So a typical compilation looks like
g++ -w -I/share/ccc3e -I/usr/X11R6/include -I/usr/include -L/usr/X11R6/lib -lX11 -o lab03/message lab03/message.cpp /share/ccc3e/ccc_x11.cpp /share/ccc3e/ccc_shap.cpp
The good news is that "Q" does this for you if you "#include" the ccc library. The above command was run when I typed
Note that it is much easier to do graphics programs in C++ in our labs rather than remotely. You need a working local C++ compiler and the Horstmann CCC library installed.
The secret of computer graphics is the Cartesian Geometry invented by Rene Descartes, where each point in the picture or on the screen is given a pair of numbers (called x and y coordinates).
Consequence: computer graphics includes a lot of mathematics.
. . . . . . . . . ( end of section 2.8 Displaying Graphical Shapes) <<Contents | End>>
Write up and hand in one of these exercises and your solution, with your name, for me to grade, before the start of class.
Programming Problem: you need to input a phone number from the user in format "123-456-7890" and extract and output the area code("123") and the seven digit phone number("4567890").