C++: Classes & Object Oriented Programming

vn/timviec-lam/programmingtraining-officer/369466 .careerlink.Class and Object Define a class What is the relation between Class and Object? Instantiate Objects http://www.

.Class and Object Class Name: Car Data Fields: Color is:___ Functions: getWidth() getHeight() A class template Car Object 1 Data Fields: Color is:_Blue__ Car Object 2 Data Fields: Color is:_Red__ Car Object 3 Data Fields: Color is:_Black__ Three objects of Car class An object has both a state and behavior. The state defines the object. and the behavior defines what the object does.

Declaration: Class      Tells the compiler what member functions and data members belong to the class. Class body is enclosed in braces ({}) Specifies data members and member functions Access-specifier public:  Indicates that a member function or data member is accessible to other functions and member functions of other classes. Keyword class followed by the class’s name. .

Define Time Class (1/3) Beginning of class definition for class Time What’s the functions of ‘public’ and ‘private’ keyword? .

Define Time Class (2/3) What’s the functions of ‘constructor’? .

Define Time Class (3/3) What’s the functions of ‘setfill’ and ‘setw’ keyword? .

hour = 13? .Main Function Use dot operator to call Time’s member function Can we call t.

Phuong Output: Phuong Minh . First: Minh.Example  Write a program that asks the user to input a name in the format last. last name Sample run:   Input a name in the format Last. first and outputs the name as first name.

Sign up to vote on this title
UsefulNot useful