string greeting = "Hello";
cout << greeting.substr(0,4);
#include "ccc_time.h"
Time sometime;
double interest_rate;
string greeting;
Time day_end = Time(23, 59, 59); /* the last second of the day */
double interest_rate = 3.5;
string greeting = "Hello";
Time day_end(23, 59, 59); /* the last second of the day */
Time now = Time(); /* the time this object is created */
Time now; /* the time this object is created */
Time later(); /* NO! */
sometime = Time(12, 5, 18); /* we already declared sometime */
Syntax 3.1: Constant Object Construction Class_name(construction parameters);
|
Syntax 3.2: Object Variable Definition Class_name variable_name(construction parameters);
|
greeting.length(); /* returns the length of greetings */
greeting.substr(0,1); /* returns a substring */
now.get_seconds(); /* returns the seconds value of now */
now.get_minutes(); /* returns the minutes value of now */
now.get_hours(); /* returns the hours value of now */
now.add_seconds(1000); /* add 1000 seconds to the time stored in now */
now.set_hours(2); /* NO! Not a supported member function */
now.set_hours(9999); /* NO! Doesn't make sense */
now.add_seconds(1000); /* Changes now to move by 1000 seconds */
now.seconds_from(day_end); /* Computes number of seconds between now and day_end */
Employee harry("Hacker, Harry", 45000.00);
cout << "Name: " << harry.get_name() << "\n";
cout << "Salary: " << harry.get_salary() << "\n";
harry.set_salary(new_salary);