- A class's data members maintain data for each object of the class, and its member functions manipulate the class' data members
- A class definition begins with keyword class followed immediately by the class's name.
- A class's body is enclosed in an opening left brace and a closing right brace
- A class definition terminates with a required semicolon
- Typically, each class definition is placed in a separate header with the .h filename extension
- Class names, member function names and data members names are all identifiers.
- By convention, variable-name identifiers begin with a lowercase letter and every word in the name after the first word begins with a capital letter (camel case)
- By convention, class names begin with an initial uppercase letter, and member function and data member names begin with an initial lowercase letter.
- Each object of a class has its own copy of the class's data members
- An object's data members exist before a program calls member functions on an object, while they are executing and after the member functions complete execution
- Data members are declared inside a class definition but outside its member functions' bodies
- The default value for a string is the empty string (i.e., "")
- Headers should never contain using directives or using declarations
- A function's return type (which appears to the left of the function's name) specifies the type of data the function returns to its caller after performing its task
- The return type void indicates that when a function completes its task, it does not return (i.e., give back) any information to its calling function.
- Parameters specify additional information the function needs to perform its task
- When you call a function, each argument value in the call's parentheses is copied inot the corresponding parameter in the member function definition
- Parameters are declared in a parameter list locate din required parentheses following a function's name. Each parameter must specify a type followed by a parameter name.
- Multiple parameters in a function definition are separated by commas
- The number an order of arguments in a function call must match the number and order of parameters in the function definition's parameter list
- Every function body is delimited by an opening left brace and a closing right race. Within the braces are one or more statements that perform the function's task(s).
- When program execution reaches a function's closing brace, the function returns to its caller
- Variables declared in a particular function's body are local variables, which can be used only in that function. When a function terminates, the values of its local variables are lost
- A function's parameters also are local variable so ftha tfunction
- The argument types in the member function call must be consistent with the type of the corresponding parameters in the member function's definition
- When a member function that specifies a return type other than void is called an dcompletes its task, it must return a result to its caller
- The return statement passes a value back to a function's caller
- A member function that does not and should not modify the object on which it's called is declared with const to the right of its parameter list
- The keyword private is an access specifier
- Access specifiers are always followed by a colon ( : )
- A private data member is accessible only to its class's member functions
- Most data-member declarations appear after the private access specifier.
- Variables or functions listed after the public access specifier are "available to the public." They can be used by other functions in the program and by member functions of other classes
- By default, everything in a class i sprivate, unless you specify otherwise
- Once you list an access specifier, everything from that point has that access until you list another access specifier
- Declaring data members private is known as data hiding, private data members are encapsulated (hidden) in an object and can be accessed only by member functions of the object's class.