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
class
andstruct
both have the same capabilities in c++- have members, functions, constructors
- different defaults:
class
all members areprivate
struct
all members arepublic
class
is a dataType- have
data members
andmember functions
- should be placed in a
.h
file
- have
object
is 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
.cpp
where functions go- implementation of code
#include "header.cpp"
- a single
main()
function for all.cpp
files
.h
is a header file that contains a class definition- no need to compile with
g++
- if you do, you will created a hidden
.gch
file and changes to.h
file will not be made - can find these with
ls -a
- if you do, you will created a hidden
#include
constants
structs
prototypes
class interfaces
- NOT function body
- NOT
#include .cpp
files
- no need to compile with
.o
is 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#includes
means system directoryg++ *.cpp
compile 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()