data abstraction
- allow you to preform data abstraction and create new dataTypes in an Object Oriented fashion
- a place to hold data and manage operations on that data
- holds functions that a consumer can call
classandstructboth have the same capabilities in c++- have members, functions, constructors
- different defaults:
classall members areprivatestructall members arepublic
classis a dataType- have
data membersandmember functions - should be placed in a
.hfile
- have
objectis an instance of a class, a variable- format:
class nameType { public: // place member functions (prototype!) private: // place private data members }; // need a semicolon
modular abstraction
- extra files to better organize code
- can come in
.cpp,.o,.h .cppwhere functions go- implementation of code
#include "header.cpp"- a single
main()function for all.cppfiles
.his a header file that contains a class definition- no need to compile with
g++- if you do, you will created a hidden
.gchfile and changes to.hfile will not be made - can find these with
ls -a
- if you do, you will created a hidden
#includeconstantsstructsprototypesclass interfaces- NOT function body
- NOT
#include .cppfiles
- no need to compile with
.ois a file that contains a pre-compiled object- this allows the object to be used by other files
- hides the code secrets of the object
- not everything is open-source in industry
<>with#includesmeans system directoryg++ *.cppcompile with multiple files- only works if all files are in the same directory
- compiler does not need a file to be named anything in particular if it contains
main()