├── .DS_Store ├── .vscode ├── c_cpp_properties.json ├── launch.json ├── settings.json └── tasks.json ├── README.md ├── Section01-Introduction └── CPP-FAQ.pdf ├── Section02-Installation_and_Setup └── readme.md ├── Section03-Curriculum_Overview └── readme.md ├── Section04-Getting_Started ├── .DS_Store ├── building_our_first_program │ ├── .vscode │ │ ├── launch.json │ │ └── tasks.json │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main ├── compiler_errors │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main ├── compiler_warnings │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main ├── section04_challenge │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main ├── section04_source_code │ ├── .DS_Store │ ├── ChallengeSolution │ │ ├── ChallengeSolution.mk │ │ ├── ChallengeSolution.project │ │ ├── ChallengeSolution.txt │ │ ├── Resources │ │ │ └── Challenge.txt │ │ └── main.cpp │ ├── CompilerErrors │ │ ├── CompilerErrors.mk │ │ ├── CompilerErrors.project │ │ └── main.cpp │ ├── CompilerWarnings │ │ ├── CompilerWarnings.mk │ │ ├── CompilerWarnings.project │ │ ├── CompilerWarnings.txt │ │ └── main.cpp │ ├── FirstProgram │ │ ├── FirstProgram.mk │ │ ├── FirstProgram.project │ │ ├── FirstProgram.txt │ │ └── main.cpp │ ├── LinkerError │ │ ├── LinkerError.mk │ │ ├── LinkerError.project │ │ ├── LinkerError.txt │ │ └── main.cpp │ ├── Makefile │ ├── Project1 │ │ ├── Project1.mk │ │ ├── Project1.project │ │ └── main.cpp │ ├── Project2 │ │ ├── Project2.mk │ │ ├── Project2.project │ │ ├── Project2.txt │ │ └── main.cpp │ └── Section4.workspace └── writing_our_first_program_helloworld │ ├── .vscode │ ├── launch.json │ └── tasks.json │ ├── helloworld │ ├── helloworld.cpp │ └── helloworld.dSYM │ └── Contents │ ├── Info.plist │ └── Resources │ └── DWARF │ └── helloworld ├── Section05-Structure_of_a_CPP_Program ├── .DS_Store ├── basic_io │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main ├── section05_coding_exercise │ └── README.md ├── section05_quiz │ └── README.md └── section05_source_code │ ├── .DS_Store │ ├── .codelite │ ├── Section5.session │ ├── Section5.tags │ ├── compilation.db │ └── refactoring.db │ ├── BasicIO │ ├── BasicIO.mk │ ├── BasicIO.project │ ├── BasicIO.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── Comments │ ├── Comments.mk │ ├── Comments.project │ └── main.cpp │ ├── Makefile │ ├── ModifiedProgram │ ├── ModifiedProgram.mk │ ├── ModifiedProgram.project │ ├── ModifiedProgram.txt │ └── main.cpp │ └── Section5.workspace ├── Section06-Variables_and_Constants ├── .DS_Store ├── readme.md ├── section06_coding_exercise │ └── README.md ├── section06_quiz │ └── README.md └── section06_source_code │ ├── .DS_Store │ ├── .codelite │ ├── Section6.session │ ├── Section6.tags │ ├── compilation.db │ └── refactoring.db │ ├── Challenge │ ├── Challenge.mk │ ├── Challenge.project │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── ChallengeSolution │ ├── ChallengeSolution.mk │ ├── ChallengeSolution.project │ ├── ChallengeSolution.txt │ └── main.cpp │ ├── Constants │ ├── Constants.mk │ ├── Constants.project │ ├── Constants.txt │ └── main.cpp │ ├── GlobalVariables │ ├── GlobalVariables.mk │ ├── GlobalVariables.project │ ├── GlobalVariables.txt │ └── main.cpp │ ├── InitializingVariables │ ├── InitializingVariables.mk │ ├── InitializingVariables.project │ ├── InitializingVariables.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── Makefile │ ├── PrimitiveTypes │ ├── PrimitiveTypes.mk │ ├── PrimitiveTypes.project │ ├── PrimitiveTypes.txt │ └── main.cpp │ ├── Section6.workspace │ └── SizeofOperator │ ├── SizeofOperator.mk │ ├── SizeofOperator.project │ ├── SizeofOperator.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ └── Contents │ ├── Info.plist │ └── Resources │ └── DWARF │ └── main ├── Section07-Arrays_and_Vectors ├── README.md ├── section07_coding_exercise │ └── README.md ├── section07_quiz │ └── README.md └── section07_source_code │ ├── .codelite │ ├── Section7.session │ ├── Section7.tags │ ├── compilation.db │ └── refactoring.db │ ├── Arrays │ ├── Arrays.mk │ ├── Arrays.project │ ├── Arrays.txt │ └── main.cpp │ ├── Challenge │ ├── Challenge.mk │ ├── Challenge.project │ ├── Challenge.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── ChallengeSolution │ ├── ChallengeSolution.mk │ ├── ChallengeSolution.project │ ├── ChallengeSolution.txt │ └── main.cpp │ ├── Makefile │ ├── Section7.workspace │ └── Vectors │ ├── Vectors.mk │ ├── Vectors.project │ ├── Vectors.txt │ └── main.cpp ├── Section08-Statements_and_Operators ├── README.md ├── section08_coding_exercise │ └── README.md ├── section08_quiz │ └── README.md └── section08_source_code │ ├── .codelite │ ├── Section8.session │ ├── Section8.tags │ ├── compilation.db │ └── refactoring.db │ ├── ArithmeticOperators │ ├── ArithmeticOperators.mk │ ├── ArithmeticOperators.project │ ├── ArithmeticOperators.txt │ └── main.cpp │ ├── AssignmentOperator │ ├── AssignmentOperator.mk │ ├── AssignmentOperator.project │ ├── AssignmentOperator.txt │ └── main.cpp │ ├── Challenge │ ├── Challenge.mk │ ├── Challenge.project │ ├── Challenge.txt │ └── main.cpp │ ├── ChallengeSolution │ ├── ChallengeSolution.mk │ ├── ChallengeSolution.project │ ├── ChallengeSolution.txt │ └── main.cpp │ ├── EqualityOperators │ ├── EqualityOperators.mk │ ├── EqualityOperators.project │ ├── EqualityOperators.txt │ └── main.cpp │ ├── Euros │ ├── Euros.mk │ ├── Euros.project │ ├── Euros.txt │ └── main.cpp │ ├── IncrementDecrementOperators │ ├── IncrementDecrementOperators.mk │ ├── IncrementDecrementOperators.project │ ├── IncrementDecrementOperators.txt │ └── main.cpp │ ├── LogicalOperators │ ├── LogicalOperators.mk │ ├── LogicalOperators.project │ ├── LogicalOperators.txt │ └── main.cpp │ ├── Makefile │ ├── MixedExpressions │ ├── MixedExpressions.mk │ ├── MixedExpressions.project │ ├── MixedExpressions.txt │ └── main.cpp │ ├── RelationalOperators │ ├── RelationalOperators.mk │ ├── RelationalOperators.project │ ├── RelationalOperators.txt │ └── main.cpp │ └── Section8.workspace ├── Section09-Controlling_Program_Flow ├── .DS_Store ├── README.md ├── section09_coding_exercise │ └── README.md ├── section09_quiz │ └── README.md └── section09_source_code │ ├── .DS_Store │ ├── Challenge │ ├── Challenge.mk │ ├── Challenge.project │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── ChallengeSolution │ ├── ChallengeSolution.mk │ ├── ChallengeSolution.project │ ├── ChallengeSolution.txt │ └── main.cpp │ ├── ConditionalOperator │ ├── ConditionalOperator.mk │ ├── ConditionalOperator.project │ ├── ConditionalOperator.txt │ └── main.cpp │ ├── DoWhile │ ├── DoWhile.mk │ ├── DoWhile.project │ ├── DoWhile.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── ForLoop │ ├── ForLoop.mk │ ├── ForLoop.project │ ├── ForLoop.txt │ └── main.cpp │ ├── Grades │ ├── Grades.mk │ ├── Grades.project │ ├── Grades.txt │ └── main.cpp │ ├── Histogram │ ├── Histogram.mk │ ├── Histogram.project │ ├── Histogram.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── IfElseStatement │ ├── IfElseStatement.mk │ ├── IfElseStatement.project │ ├── IfElseStatement.txt │ └── main.cpp │ ├── IfStatement │ ├── IfStatement.mk │ ├── IfStatement.project │ ├── IfStatement.txt │ └── main.cpp │ ├── Makefile │ ├── MultiplcationTable │ ├── MultiplcationTable.mk │ ├── MultiplcationTable.project │ ├── MultiplcationTable.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── RangeBasedForLoop │ ├── RangeBasedForLoop.mk │ ├── RangeBasedForLoop.project │ ├── RangeBasedForLoop.txt │ └── main.cpp │ ├── Section9.workspace │ ├── Shipping │ ├── Shipping.mk │ ├── Shipping.project │ ├── Shipping.txt │ └── main.cpp │ ├── Switch │ ├── Switch.mk │ ├── Switch.project │ ├── Switch.txt │ └── main.cpp │ ├── SwitchEnum │ ├── SwitchEnum.mk │ ├── SwitchEnum.project │ ├── SwitchEnum.txt │ └── main.cpp │ └── WhileLoop │ ├── WhileLoop.mk │ ├── WhileLoop.project │ ├── WhileLoop.txt │ └── main.cpp ├── Section10_Characters_and_Strings ├── .DS_Store ├── README.md ├── section10_coding_exercise │ └── README.md ├── section10_quiz │ └── README.md └── section10_source_code │ ├── .codelite │ ├── Section10.session │ ├── Section10.tags │ ├── compilation.db │ └── refactoring.db │ ├── CPPStrings │ ├── CPPStrings.mk │ ├── CPPStrings.project │ ├── CPPStrings.txt │ └── main.cpp │ ├── CStyleStrings │ ├── CStyleStrings.mk │ ├── CStyleStrings.project │ ├── CStyleStrings.txt │ └── main.cpp │ ├── Challenge │ ├── Challenge.mk │ ├── Challenge.project │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── ChallengeSolution │ ├── ChallengeSolution.mk │ ├── ChallengeSolution.project │ ├── ChallengeSolution.txt │ └── main.cpp │ ├── CharFunctions │ ├── CharFunctions.mk │ ├── CharFunctions.project │ ├── CharFunctions.txt │ └── main.cpp │ ├── Makefile │ └── Section10.workspace ├── Section11_Functions ├── .DS_Store ├── README.md ├── section11_coding_exercise │ └── README.md ├── section11_quiz │ └── README.md └── section11_source_code │ ├── .codelite │ ├── Section11.session │ ├── Section11.tags │ ├── compilation.db │ └── refactoring.db │ ├── ArraysAndFunctions │ ├── ArraysAndFunctions.mk │ ├── ArraysAndFunctions.project │ ├── ArraysAndFunctions.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── Challenge │ ├── Challenge.mk │ ├── Challenge.project │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── ChallengeSolution │ ├── ChallengeSolution.mk │ ├── ChallengeSolution.project │ ├── ChallengeSolution.txt │ └── main.cpp │ ├── DefaultArguments │ ├── DefaultArguments.mk │ ├── DefaultArguments.project │ ├── DefaultArguments.txt │ └── main.cpp │ ├── Factorial │ ├── Factorial.mk │ ├── Factorial.project │ ├── Factorial.txt │ └── main.cpp │ ├── Fibonacci │ ├── Fibonacci.mk │ ├── Fibonacci.project │ ├── Fibonacci.txt │ └── main.cpp │ ├── FunctionDefinitions │ ├── FunctionDefinitions.mk │ ├── FunctionDefinitions.project │ ├── FunctionDefinitions.txt │ └── main.cpp │ ├── FunctionOverloading │ ├── FunctionOverloading.mk │ ├── FunctionOverloading.project │ ├── FunctionOverloading.txt │ └── main.cpp │ ├── FunctionParamters │ ├── FunctionParameters.mk │ ├── FunctionParameters.txt │ ├── FunctionParamters.project │ └── main.cpp │ ├── FunctionPrototypes │ ├── FunctionPrototypes.mk │ ├── FunctionPrototypes.project │ ├── FunctionPrototypes.txt │ └── main.cpp │ ├── HowFunctionCallsWork │ ├── HowFunctionCallsWork.mk │ ├── HowFunctionCallsWork.project │ ├── HowFunctionCallsWork.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── Makefile │ ├── Math │ ├── Math.mk │ ├── Math.project │ ├── Math.txt │ └── main.cpp │ ├── PassByReference │ ├── PassByReference.mk │ ├── PassByReference.project │ ├── PassByReference.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── Random │ ├── Random.mk │ ├── Random.project │ ├── Random.txt │ └── main.cpp │ ├── ScopeExample │ ├── ScopeExample.mk │ ├── ScopeExample.project │ ├── ScopeExample.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ └── Section11.workspace ├── Section12_Pointers_and_Reference ├── .DS_Store ├── README.md ├── section12_quiz │ └── README.md └── section12_source_code │ ├── .codelite │ ├── Section12.session │ ├── Section12.tags │ ├── compilation.db │ ├── cppcheck.list │ └── refactoring.db │ ├── AraysAndPointers │ ├── AraysAndPointers.project │ ├── ArraysAndPointers.mk │ ├── ArraysAndPointers.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── Challenge │ ├── Challenge.mk │ ├── Challenge.project │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── ChallengeSolution │ ├── ChallengeSolution.mk │ ├── ChallengeSolution.project │ ├── ChallengeSolution.txt │ └── main.cpp │ ├── Debugger │ ├── Debugger.mk │ ├── Debugger.project │ ├── Debugger.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── Dereference │ ├── Dereference.mk │ ├── Dereference.project │ ├── Dereference.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── DynamicMemory │ ├── DynamicMemory.mk │ ├── DynamicMemory.project │ ├── DynamicMemory.txt │ └── main.cpp │ ├── Makefile │ ├── PassingPointers │ ├── PassingPointers.mk │ ├── PassingPointers.project │ ├── PassingPointers.txt │ ├── PassingPointers1.mk │ ├── PassingPointers1.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── PassingPointers2 │ ├── PassingPointers2.mk │ ├── PassingPointers2.project │ ├── PassingPointers2.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── PassingPointers3 │ ├── PassingPointers3.mk │ ├── PassingPointers3.project │ ├── PassingPointers3.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── PointerArithmetic │ ├── PointerArithmetic.mk │ ├── PointerArithmetic.project │ ├── PointerArithmetic.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── References │ ├── References.mk │ ├── References.project │ ├── References.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── ReturnPointer │ ├── ReturnPointer.mk │ ├── ReturnPointer.project │ ├── ReturnPointer.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── Section12.workspace │ └── SimplePointers │ ├── SimplePointers.mk │ ├── SimplePointers.project │ ├── SimplePointers.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ └── Contents │ ├── Info.plist │ └── Resources │ └── DWARF │ └── main ├── Section13_OOP-Classes_and_Objects ├── .DS_Store ├── README.md ├── section13_coding_exercise │ └── README.md ├── section13_quiz │ └── README.md └── section13_source_code │ ├── .DS_Store │ ├── .codelite │ ├── Section13.session │ ├── Section13.tags │ ├── Section13.workspace.frank │ ├── compilation.db │ └── refactoring.db │ ├── AccessModifiers │ ├── AccessModifiers.mk │ ├── AccessModifiers.project │ ├── AccessModifiers.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── AccessingClassMembers │ ├── AccessingClassMembers.mk │ ├── AccessingClassMembers.project │ ├── AccessingClassMembers.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── Challenge │ ├── Challenge.mk │ ├── Challenge.project │ ├── Description.txt │ ├── Movie.cpp │ ├── Movie.h │ ├── Movies.cpp │ ├── Movies.dSYM │ │ └── Contents │ │ │ ├── Info.plist │ │ │ └── Resources │ │ │ └── DWARF │ │ │ └── Movies │ ├── Movies.h │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── ChallengeSolution │ ├── ChallengeSolution.mk │ ├── ChallengeSolution.project │ ├── ChallengeSolution.txt │ ├── Description.txt │ ├── Movie.cpp │ ├── Movie.h │ ├── Movies.cpp │ ├── Movies.h │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── ConstInClasses │ ├── ConstInClasses.mk │ ├── ConstInClasses.project │ ├── ConstInClasses.txt │ └── main.cpp │ ├── ConstructorInitializationLists │ ├── ConstructorInitializationLists.mk │ ├── ConstructorInitializationLists.project │ ├── ConstructorInitializationLists.txt │ └── main.cpp │ ├── ConstructorsAndDestructors │ ├── ConstructorsAndDestructors.mk │ ├── ConstructorsAndDestructors.project │ ├── ConstructorsAndDestructors.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── CopyConstructor │ ├── CopyConstructor.mk │ ├── CopyConstructor.project │ ├── CopyConstructor.txt │ └── main.cpp │ ├── DeclareClassAndObjects │ ├── DeclareClassAndObjects.mk │ ├── DeclareClassAndObjects.project │ ├── DeclareClassAndObjects.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── DeepCopy │ ├── DeepCopy.mk │ ├── DeepCopy.project │ ├── DeepCopy.txt │ └── main.cpp │ ├── DefaultConstructor │ ├── DefaultConstructor.mk │ ├── DefaultConstructor.project │ ├── DefaultConstructor.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── DefaultConstructorParameters │ ├── DefaultConstructorParameters.mk │ ├── DefaultConstructorParameters.project │ ├── DefaultConstructorParameters.txt │ └── main.cpp │ ├── DelegatingConstructors │ ├── DelegatingConstructors.mk │ ├── DelegatingConstructors.project │ ├── DelegatingConstructors.txt │ └── main.cpp │ ├── Friends │ ├── Friend_class.cpp │ ├── Friend_class.h │ ├── Friends.mk │ ├── Friends.project │ ├── Friends.txt │ ├── Other_class.cpp │ ├── Other_class.h │ ├── Player.cpp │ ├── Player.h │ └── main.cpp │ ├── ImplementingMethods │ ├── ImplementingMethods.project │ ├── ImplementingMethods1.mk │ ├── ImplementingMethods1.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── ImplementingMethods2 │ ├── Account.cpp │ ├── Account.h │ ├── ImplementingMethods2.mk │ ├── ImplementingMethods2.project │ ├── ImplementingMethods2.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── Makefile │ ├── MoveConstructor │ ├── MoveConstructor.mk │ ├── MoveConstructor.project │ ├── MoveConstructor.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ ├── Section13.workspace │ ├── ShallowCopy │ ├── ShallowCopy.mk │ ├── ShallowCopy.project │ ├── ShallowCopy.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ └── DWARF │ │ └── main │ └── StaticClassMembers │ ├── Player.cpp │ ├── Player.h │ ├── StaticClassMembers.mk │ ├── StaticClassMembers.project │ ├── StaticClassMembers.txt │ ├── main │ ├── main.cpp │ └── main.dSYM │ └── Contents │ ├── Info.plist │ └── Resources │ └── DWARF │ └── main ├── Section14-OperatorOverloading └── section14_source_code │ ├── .codelite │ ├── Section14.session │ ├── Section14.tags │ ├── Section14.workspace.frank │ ├── compilation.db │ ├── cppcheck.list │ └── refactoring.db │ ├── Challenge-Solution1 │ ├── Challenge-Solution1.mk │ ├── Challenge-Solution1.project │ ├── Challenge-Solution1.txt │ ├── Mystring.cpp │ ├── Mystring.h │ └── main.cpp │ ├── Challenge-Solution2 │ ├── Challenge-Solution2.mk │ ├── Challenge-Solution2.project │ ├── Challenge-Solution2.txt │ ├── Mystring.cpp │ ├── Mystring.h │ └── main.cpp │ ├── Challenge │ ├── Challenge.mk │ ├── Challenge.project │ ├── Challenge.txt │ ├── Description.txt │ ├── Mystring.cpp │ ├── Mystring.h │ └── main.cpp │ ├── Makefile │ ├── Mystring-copy-assignment │ ├── Mystring-copy-assignment.mk │ ├── Mystring-copy-assignment.project │ ├── Mystring-copy-assignment.txt │ ├── Mystring.cpp │ ├── Mystring.h │ └── main.cpp │ ├── Mystring-insertion-extraction │ ├── Mystring-insertion-extraction.mk │ ├── Mystring-insertion-extraction.project │ ├── Mystring-insertion-extraction.txt │ ├── Mystring.cpp │ ├── Mystring.h │ └── main.cpp │ ├── Mystring-move-assignment │ ├── Mystring-move-assignment.mk │ ├── Mystring-move-assignment.project │ ├── Mystring-move-assignment.txt │ ├── Mystring.cpp │ ├── Mystring.h │ └── main.cpp │ ├── Mystring-operator-functions │ ├── Mystring-operator-functions.mk │ ├── Mystring-operator-functions.project │ ├── Mystring-operator-functions.txt │ ├── Mystring.cpp │ ├── Mystring.h │ └── main.cpp │ ├── Mystring-operators │ ├── Mystring-operator-methods.mk │ ├── Mystring-operator-methods.txt │ ├── Mystring-operators.mk │ ├── Mystring-operators.project │ ├── Mystring-operators.txt │ ├── Mystring.cpp │ ├── Mystring.h │ └── main.cpp │ ├── Mystring-start │ ├── Mystring-start.mk │ ├── Mystring-start.project │ ├── Mystring-start.txt │ ├── Mystring.cpp │ ├── Mystring.h │ └── main.cpp │ └── Section14.workspace └── Section22-Bonus_Section-Using_Visual_Studio_Code ├── readme.md ├── test1 ├── test1 ├── test1.cpp └── test1.dSYM │ └── Contents │ ├── Info.plist │ └── Resources │ └── DWARF │ └── test1 └── test2 ├── test2 ├── test2.cpp └── test2.dSYM └── Contents ├── Info.plist └── Resources └── DWARF └── test2 /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/.DS_Store -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Mac", 5 | "includePath": [ 6 | "${workspaceFolder}/**" 7 | ], 8 | "defines": [], 9 | "macFrameworkPath": [ 10 | "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks" 11 | ], 12 | "compilerPath": "/usr/bin/g++", 13 | "cStandard": "gnu17", 14 | "cppStandard": "c++20", 15 | "intelliSenseMode": "macos-gcc-arm64" 16 | } 17 | ], 18 | "version": 4 19 | } -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "g++ - Build and debug active file", 9 | "type": "lldb", 10 | "request": "launch", 11 | "program": "${fileDirname}/${fileBasenameNoExtension}", 12 | "args": [], 13 | "cwd": "${fileDirname}", 14 | "preLaunchTask": "C/C++: g++ build active file" 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "type": "cppbuild", 6 | "label": "C/C++: g++ build active file", 7 | "command": "/usr/bin/g++", 8 | "args": [ 9 | "-fdiagnostics-color=always", 10 | "-g", 11 | "-Wall", 12 | "-std=c++20", 13 | "${fileDirname}/*.cpp", 14 | "-o", 15 | "${fileDirname}/${fileBasenameNoExtension}" 16 | ], 17 | "options": { 18 | "cwd": "${fileDirname}" 19 | }, 20 | "problemMatcher": [ 21 | "$gcc" 22 | ], 23 | "group": { 24 | "kind": "build", 25 | "isDefault": true 26 | }, 27 | "detail": "compiler: /usr/bin/g++" 28 | } 29 | ] 30 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Beginning C++ Programming - From Beginner to Beyond 2 | This repository showcase my progress with the course from Udemy. 3 | ## Platform 4 | 1. MacOS Big Sur --version 11.3 5 | 2. Visual Studio Code 6 | 3. Command-Line Interface / through VS Code to compile codes 7 | ## Progress 8 | - [x] Section 1: Introduction 9 | - [x] Section 2: Installation and Setup 10 | - [x] Section 3: Curriculum Overview 11 | - [x] Section 4: Getting Started 12 | - [x] Section 5: Structure of a C++ Program 13 | - [x] Section 6: Variables and Constants 14 | - [x] Section 7: Arrays and Vectors 15 | - [x] Section 8: Statements and Operators 16 | - [x] Section 9: Controlling Program Flow 17 | - [x] Section 10: Characters and Strings 18 | - [x] Section 11: Functions 19 | - [x] Section 12: Pointers and References 20 | - [x] Section 13: OPP - Classes and Objects 21 | - [ ] Section 14: Operator Overloading 22 | - [ ] Section 15: Inheritance 23 | - [ ] Section 16: Polymorphism 24 | - [ ] Section 17: Smart Pointers 25 | - [ ] Section 18: Exception Handling 26 | - [ ] Section 19: I/O and Streams 27 | - [ ] Section 20: The Standard Template Library (STL) 28 | - [ ] Section 21: Lambda Expressions 29 | - [x] Section 22: Bonus Section - Using Visual Studio Code 30 | - [ ] Section 23: Bonus Section - Enumerations 31 | - [ ] Section 24: ARCHIVED - OLD INSTALLATION VIDEOS 32 | - [x] Section 25: Extra Infromation - Source code, and other stuff 33 | - [x] Section 26: Bonus Section - inculding Slides 34 | 35 | -------------------------------------------------------------------------------- /Section01-Introduction/CPP-FAQ.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section01-Introduction/CPP-FAQ.pdf -------------------------------------------------------------------------------- /Section02-Installation_and_Setup/readme.md: -------------------------------------------------------------------------------- 1 | - Instructor prefers [CodeLite](https://codelite.org/) but I am already using VSCode and [Section 22](https://github.com/yanth0nyy/Beginning_CPP_Programming/tree/master/Section22-Bonus_Section-Using_Visual_Studio_Code) walks through VSCode installation, building and running C++ programs. 2 | - I also started learning C++ programming with free and online platform. So I had most of the basic set up per [Microsoft's instuctions](https://code.visualstudio.com/docs/cpp/config-clang-mac) 3 | - Notice the insturctor prefers `g++` over `clang`, `c++17` over `c++20`, and using another debugger. They are all documented under [Section 22](https://github.com/yanth0nyy/Beginning_CPP_Programming/tree/master/Section22-Bonus_Section-Using_Visual_Studio_Code). -------------------------------------------------------------------------------- /Section03-Curriculum_Overview/readme.md: -------------------------------------------------------------------------------- 1 | Nothing much here... -------------------------------------------------------------------------------- /Section04-Getting_Started/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section04-Getting_Started/.DS_Store -------------------------------------------------------------------------------- /Section04-Getting_Started/building_our_first_program/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "clang++ - Build and debug active file", 9 | "type": "cppdbg", 10 | "request": "launch", 11 | "program": "${fileDirname}/${fileBasenameNoExtension}", 12 | "args": [], 13 | "stopAtEntry": false, 14 | "cwd": "${workspaceFolder}", 15 | "environment": [], 16 | "externalConsole": false, 17 | "MIMode": "lldb", 18 | "preLaunchTask": "C/C++: clang++ build active file" 19 | } 20 | ] 21 | } -------------------------------------------------------------------------------- /Section04-Getting_Started/building_our_first_program/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "tasks": [ 3 | { 4 | "type": "cppbuild", 5 | "label": "C/C++: clang++ build active file", 6 | "command": "/usr/bin/clang++", 7 | "args": [ 8 | "-g", 9 | "${file}", 10 | "-o", 11 | "${fileDirname}/${fileBasenameNoExtension}" 12 | ], 13 | "options": { 14 | "cwd": "${workspaceFolder}" 15 | }, 16 | "problemMatcher": [ 17 | "$gcc" 18 | ], 19 | "group": { 20 | "kind": "build", 21 | "isDefault": true 22 | }, 23 | "detail": "Task generated by Debugger." 24 | } 25 | ], 26 | "version": "2.0.0" 27 | } -------------------------------------------------------------------------------- /Section04-Getting_Started/building_our_first_program/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section04-Getting_Started/building_our_first_program/main -------------------------------------------------------------------------------- /Section04-Getting_Started/building_our_first_program/main.cpp: -------------------------------------------------------------------------------- 1 | #include // input and output library 2 | 3 | int main(){ 4 | // Declare variable with type 5 | int num; 6 | 7 | // Prompt string on terminal 8 | std::cout << "Enter your favorite number between 1 and 100: "; 9 | // What std::cout mean? https://www.cplusplus.com/forum/beginner/61121/ 10 | // std::cout tells the compiler that I want the "cout" identifier, and that it is in the "std" namespace 11 | // [namespace][scope resolution operator][identifier] 12 | 13 | // Take input from terminal 14 | std::cin >> num; 15 | // Similar to "cout", "cin" takes input 16 | 17 | // Display on terminal after user input and end line + move cursor to next line 18 | std::cout << "Amazing! That's my favorite number too!" << std::endl; 19 | 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Section04-Getting_Started/building_our_first_program/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section04-Getting_Started/building_our_first_program/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section04-Getting_Started/building_our_first_program/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section04-Getting_Started/compiler_errors/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section04-Getting_Started/compiler_errors/main -------------------------------------------------------------------------------- /Section04-Getting_Started/compiler_errors/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section04-Getting_Started/compiler_errors/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section04-Getting_Started/compiler_errors/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section04-Getting_Started/compiler_warnings/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section04-Getting_Started/compiler_warnings/main -------------------------------------------------------------------------------- /Section04-Getting_Started/compiler_warnings/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | int num; 6 | 7 | // num = 100; 8 | 9 | std::cout << num << std::endl; 10 | 11 | return 0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /Section04-Getting_Started/compiler_warnings/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section04-Getting_Started/compiler_warnings/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section04-Getting_Started/compiler_warnings/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section04-Getting_Started/section04_challenge/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section04-Getting_Started/section04_challenge/main -------------------------------------------------------------------------------- /Section04-Getting_Started/section04_challenge/main.cpp: -------------------------------------------------------------------------------- 1 | /* Section 4 Challenge 2 | ====================== 3 | 4 | Create a C++ program that asks the user for their favorite number between 1 and 100 5 | that read this number from console. 6 | 7 | Suppose the user enters 24 8 | 9 | Then display the following to the console: 10 | Amazing!! That's my favprite number too? 11 | No really!! 24 is my favorite number! 12 | 13 | ====================== 14 | Enter your favorite number between 1 and 100: 24 15 | Amazing!! That's my favprite number too? 16 | No really!! 24 is my favorite number! 17 | 18 | */ 19 | 20 | #include 21 | 22 | int main(){ 23 | int num; 24 | std::cout << "Enter your favorite number between 1 and 100: "; 25 | 26 | std::cin >> num; 27 | 28 | if (num > 0 && num < 101){ 29 | std::cout << "Amazing!! That's my favprite number too?" << std::endl << "No really!! " << num << " is my favorite number!" << std::endl; 30 | } 31 | 32 | return 0; 33 | } 34 | 35 | -------------------------------------------------------------------------------- /Section04-Getting_Started/section04_challenge/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section04-Getting_Started/section04_challenge/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section04-Getting_Started/section04_challenge/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section04-Getting_Started/section04_source_code/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section04-Getting_Started/section04_source_code/.DS_Store -------------------------------------------------------------------------------- /Section04-Getting_Started/section04_source_code/ChallengeSolution/ChallengeSolution.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section04-Getting_Started/section04_source_code/ChallengeSolution/Resources/Challenge.txt: -------------------------------------------------------------------------------- 1 | Section 4 Challenge 2 | ============= 3 | 4 | Create a C++ program that asks the user for their favorite number between 1 and 100 5 | then read this number from the console. 6 | 7 | Suppose the user enters 24. 8 | 9 | Then display the following to the console: 10 | 11 | Amazing!! That's my favorite number too! 12 | No really!!, 24 is my favorite number! 13 | 14 | 15 | Below are 2 sample runs of the program: 16 | ======================================= 17 | Enter your favorite number between 1 and 100: 24 18 | Amazing!! That's my favorite number too! 19 | No really!!, 24 is my favorite number! 20 | 21 | 22 | Enter your favorite number between 1 and 100: 75 23 | Amazing!! That's my favorite number too! 24 | No really!!, 75 is my favorite number! -------------------------------------------------------------------------------- /Section04-Getting_Started/section04_source_code/ChallengeSolution/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | 5 | int favorite_number; 6 | 7 | std::cout << "Enter your favorite number between 1 and 100: "; 8 | std::cin >> favorite_number; 9 | 10 | std::cout << "Amazing!! That's my favorite number too!" << std::endl; 11 | 12 | std::cout << "No really!!, " << favorite_number << " is my favorite number!" << std::endl; 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /Section04-Getting_Started/section04_source_code/CompilerErrors/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | std::cout << ("Hello world" / 125) << std::endl; 6 | return 0; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /Section04-Getting_Started/section04_source_code/CompilerWarnings/CompilerWarnings.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section04-Getting_Started/section04_source_code/CompilerWarnings/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | 5 | int favorite_number; 6 | 7 | std::cout << "Hello world" << std::endl; 8 | return 0; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /Section04-Getting_Started/section04_source_code/FirstProgram/FirstProgram.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section04-Getting_Started/section04_source_code/FirstProgram/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int favorite_number; 6 | 7 | std::cout << "Enter your favorite number between 1 and 100: "; 8 | std::cin >> favorite_number; 9 | std::cout << "Amazing!! That's my favorite number too!" << std::endl; 10 | 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /Section04-Getting_Started/section04_source_code/LinkerError/LinkerError.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section04-Getting_Started/section04_source_code/LinkerError/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern int x; 4 | 5 | int main() { 6 | 7 | std::cout << "Hello world" << std::endl; 8 | 9 | std::cout << x; 10 | 11 | return 0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /Section04-Getting_Started/section04_source_code/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean All 2 | 3 | All: 4 | @echo "----------Building project:[ Project1 - Debug ]----------" 5 | @cd "Project1" && "$(MAKE)" -f "Project1.mk" 6 | clean: 7 | @echo "----------Cleaning project:[ Project1 - Debug ]----------" 8 | @cd "Project1" && "$(MAKE)" -f "Project1.mk" clean 9 | -------------------------------------------------------------------------------- /Section04-Getting_Started/section04_source_code/Project1/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | std::cout << "Hello Project 1" << std::endl; 5 | return 0; 6 | } 7 | 8 | -------------------------------------------------------------------------------- /Section04-Getting_Started/section04_source_code/Project2/Project2.txt: -------------------------------------------------------------------------------- 1 | ./Release/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section04-Getting_Started/section04_source_code/Project2/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | std::cout << "Hello Project 2" << std::endl; 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /Section04-Getting_Started/writing_our_first_program_helloworld/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "type": "shell", 6 | "label": "clang++ build active file", 7 | "command": "/usr/bin/clang++", 8 | "args": [ 9 | "-std=c++17", 10 | "-stdlib=libc++", 11 | "-g", 12 | "${file}", 13 | "-o", 14 | "${fileDirname}/${fileBasenameNoExtension}" 15 | ], 16 | "options": { 17 | "cwd": "${workspaceFolder}" 18 | }, 19 | "problemMatcher": [ 20 | "$gcc" 21 | ], 22 | "group": "build" 23 | }, 24 | { 25 | "type": "cppbuild", 26 | "label": "C/C++: clang++ build active file", 27 | "command": "/usr/bin/clang++", 28 | "args": [ 29 | "-g", 30 | "${file}", 31 | "-o", 32 | "${fileDirname}/${fileBasenameNoExtension}" 33 | ], 34 | "options": { 35 | "cwd": "${workspaceFolder}" 36 | }, 37 | "problemMatcher": [ 38 | "$gcc" 39 | ], 40 | "group": { 41 | "kind": "build", 42 | "isDefault": true 43 | }, 44 | "detail": "Task generated by Debugger." 45 | } 46 | ] 47 | } -------------------------------------------------------------------------------- /Section04-Getting_Started/writing_our_first_program_helloworld/helloworld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section04-Getting_Started/writing_our_first_program_helloworld/helloworld -------------------------------------------------------------------------------- /Section04-Getting_Started/writing_our_first_program_helloworld/helloworld.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() 8 | { 9 | vector msg {"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"}; 10 | 11 | for (const string& word : msg) 12 | { 13 | cout << word << " "; 14 | } 15 | cout << endl; 16 | } -------------------------------------------------------------------------------- /Section04-Getting_Started/writing_our_first_program_helloworld/helloworld.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.helloworld 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section04-Getting_Started/writing_our_first_program_helloworld/helloworld.dSYM/Contents/Resources/DWARF/helloworld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section04-Getting_Started/writing_our_first_program_helloworld/helloworld.dSYM/Contents/Resources/DWARF/helloworld -------------------------------------------------------------------------------- /Section05-Structure_of_a_CPP_Program/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section05-Structure_of_a_CPP_Program/.DS_Store -------------------------------------------------------------------------------- /Section05-Structure_of_a_CPP_Program/basic_io/main.cpp: -------------------------------------------------------------------------------- 1 | //Section 5 2 | // Basic I/O using cin and cout 3 | 4 | #include 5 | 6 | int main(){ 7 | 8 | // std::cout << "Hello world!" << std::endl; 9 | 10 | // std::cout << "Hello"; 11 | // std::cout << "World" << std::endl; 12 | 13 | // \n also works as new line 14 | // std::cout << "Hello world!" << std::endl; 15 | // std::cout << "Hello" << "world!" << std::endl; 16 | // std::cout << "Hello" << " world!\n"; 17 | // std::cout << "Hello\nOut\nThere\n"; 18 | 19 | 20 | int num1; 21 | int num2; 22 | double num3; 23 | 24 | // std::cout << "Enter an integer: "; 25 | // std::cin >> num1; 26 | // std::cout << "You entered: " << num1 << std::endl; 27 | // // white-space == will be ignored: 28 | // // input1: "123" --> output1: "You entered: 123" 29 | // // input2: " 123 " --> output2: "You entered: 123" 30 | 31 | std::cout << "Enter a first integer: "; 32 | std::cin >> num1; 33 | std::cout << "Enter a second integer: "; 34 | std::cin >> num2; 35 | std::cout << "You entered: " << num1 << " and " << num2 << std::endl; 36 | 37 | } -------------------------------------------------------------------------------- /Section05-Structure_of_a_CPP_Program/basic_io/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section05-Structure_of_a_CPP_Program/basic_io/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section05-Structure_of_a_CPP_Program/basic_io/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section05-Structure_of_a_CPP_Program/section05_source_code/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section05-Structure_of_a_CPP_Program/section05_source_code/.DS_Store -------------------------------------------------------------------------------- /Section05-Structure_of_a_CPP_Program/section05_source_code/.codelite/Section5.session: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Section05-Structure_of_a_CPP_Program/section05_source_code/.codelite/Section5.tags: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section05-Structure_of_a_CPP_Program/section05_source_code/.codelite/Section5.tags -------------------------------------------------------------------------------- /Section05-Structure_of_a_CPP_Program/section05_source_code/.codelite/compilation.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section05-Structure_of_a_CPP_Program/section05_source_code/.codelite/compilation.db -------------------------------------------------------------------------------- /Section05-Structure_of_a_CPP_Program/section05_source_code/.codelite/refactoring.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section05-Structure_of_a_CPP_Program/section05_source_code/.codelite/refactoring.db -------------------------------------------------------------------------------- /Section05-Structure_of_a_CPP_Program/section05_source_code/BasicIO/BasicIO.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section05-Structure_of_a_CPP_Program/section05_source_code/BasicIO/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section05-Structure_of_a_CPP_Program/section05_source_code/BasicIO/main -------------------------------------------------------------------------------- /Section05-Structure_of_a_CPP_Program/section05_source_code/BasicIO/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section05-Structure_of_a_CPP_Program/section05_source_code/BasicIO/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section05-Structure_of_a_CPP_Program/section05_source_code/BasicIO/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section05-Structure_of_a_CPP_Program/section05_source_code/Comments/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 5 2 | // Comments 3 | 4 | /***************************************************** 5 | * author Frank 6 | * 7 | * 11/11/2017 Frank - fixed bug in ... 8 | * 11/13/2017 Joe - Added function to... 9 | * 10 | ****************************************************/ 11 | 12 | #include 13 | 14 | // This is a comment 15 | 16 | /* This is a multiple 17 | line 18 | comment 19 | */ 20 | 21 | // Using a modified version Dijkstra's algorithm to improve space efficiency 22 | 23 | int main() 24 | { 25 | int favorite_number; // this is where my favorite number is stored 26 | 27 | std::cout << "Enter your favorite number between 1 and 100: "; 28 | 29 | std::cin >> favorite_number; /* comment */ 30 | 31 | std::cout << "Amazing!! That's my favorite number too!" << std::endl; 32 | std::cout << "No really!!, " << favorite_number << " is my favorite number!" << std::endl; 33 | 34 | return 0; // return 0 35 | } 36 | 37 | 38 | -------------------------------------------------------------------------------- /Section05-Structure_of_a_CPP_Program/section05_source_code/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean All 2 | 3 | All: 4 | @echo "----------Building project:[ ModifiedProgram - Debug ]----------" 5 | @cd "ModifiedProgram" && "$(MAKE)" -f "ModifiedProgram.mk" 6 | clean: 7 | @echo "----------Cleaning project:[ ModifiedProgram - Debug ]----------" 8 | @cd "ModifiedProgram" && "$(MAKE)" -f "ModifiedProgram.mk" clean 9 | -------------------------------------------------------------------------------- /Section05-Structure_of_a_CPP_Program/section05_source_code/ModifiedProgram/ModifiedProgram.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section05-Structure_of_a_CPP_Program/section05_source_code/ModifiedProgram/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int favorite_number; 6 | 7 | std::cout << "Enter your favorite number between 1 and 100: "; 8 | 9 | std::cin >> favorite_number; std::cout << "Amazing!! That's my favorite number too!" << std::endl; 10 | std::cout << "No really!!, " << favorite_number << " is my favorite number!" << std::endl; 11 | 12 | return 0; 13 | } 14 | 15 | 16 | -------------------------------------------------------------------------------- /Section05-Structure_of_a_CPP_Program/section05_source_code/Section5.workspace: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section06-Variables_and_Constants/.DS_Store -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_coding_exercise/README.md: -------------------------------------------------------------------------------- 1 | # Coding Exercise 1: Declaring and Initializing Variables 2 | 3 | You must declare a totale of **THREE** variables, each of a different type, to represent the employee's **name**, **age**, and **hourly_wage**. 4 | 5 | - `age` should be an `int` 6 | - `name` should be a `string` 7 | - `hourly_wage` should be a `double` 8 | 9 | - You must initialize the **hourly_wage** to **23.50**. In order to set the values 10 | - For **name** and **age** you must use `cin` and the extraction operator `>>` to allow the employee to enter their **name** and **age** in that order separated by a single space. 11 | 12 | 13 | ## Solution 14 | 15 | ```c++ 16 | #include 17 | #include 18 | using namespace std; 19 | 20 | void employee_profile() { 21 | 22 | //----WRITE YOUR CODE BELOW THIS LINE---- 23 | 24 | double hourly_wage {23.50}; 25 | 26 | string name; 27 | cin >> name; 28 | 29 | int age {0}; 30 | cin >> age; 31 | 32 | //----WRITE YOUR CODE ABOVE THIS LINE---- 33 | //----DO NOT MODIFY THE CODE BELOW THIS LINE---- 34 | 35 | cout << name << " " << age << " " << hourly_wage; 36 | } 37 | ``` -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_source_code/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section06-Variables_and_Constants/section06_source_code/.DS_Store -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_source_code/.codelite/Section6.session: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_source_code/.codelite/Section6.tags: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section06-Variables_and_Constants/section06_source_code/.codelite/Section6.tags -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_source_code/.codelite/compilation.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section06-Variables_and_Constants/section06_source_code/.codelite/compilation.db -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_source_code/.codelite/refactoring.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section06-Variables_and_Constants/section06_source_code/.codelite/refactoring.db -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_source_code/Challenge/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section06-Variables_and_Constants/section06_source_code/Challenge/main -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_source_code/Challenge/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_source_code/Challenge/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section06-Variables_and_Constants/section06_source_code/Challenge/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_source_code/ChallengeSolution/ChallengeSolution.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_source_code/Constants/Constants.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_source_code/GlobalVariables/GlobalVariables.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_source_code/GlobalVariables/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 6 2 | // Global and local variables 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | int age {18}; // Global variable 9 | 10 | int main() { 11 | 12 | int age {16}; // local variable 13 | 14 | cout << age << endl; 15 | 16 | return 0; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_source_code/InitializingVariables/InitializingVariables.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_source_code/InitializingVariables/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section06-Variables_and_Constants/section06_source_code/InitializingVariables/main -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_source_code/InitializingVariables/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 6 2 | // Declaring and initializing variables 3 | #include 4 | 5 | using namespace std; 6 | 7 | 8 | int main() { 9 | 10 | int room_width {0}; 11 | int room_length {0}; 12 | 13 | cout << "Enter the width of the room: "; 14 | cin >> room_width; 15 | 16 | cout << "Enter the length of the room: "; 17 | cin >> room_length; 18 | 19 | cout << "The area of the room is " << room_width * room_length << " square feet." << endl; 20 | 21 | return 0; 22 | } 23 | 24 | 25 | 26 | 27 | 28 | /* 29 | // This program will calculate the area of a room in square feet 30 | 31 | int main() { 32 | 33 | cout << "Enter the width of the room: "; 34 | int room_width {0}; 35 | cin >> room_width; 36 | 37 | cout << "Enter the length of the room: "; 38 | int room_length {0}; 39 | cin >> room_length; 40 | 41 | cout << "The area of the room is " << room_width * room_length << " square feet" << endl; 42 | 43 | return 0; 44 | } 45 | */ 46 | -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_source_code/InitializingVariables/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_source_code/InitializingVariables/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section06-Variables_and_Constants/section06_source_code/InitializingVariables/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_source_code/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean All 2 | 3 | All: 4 | @echo "----------Building project:[ InitializingVariables - Debug ]----------" 5 | @cd "InitializingVariables" && "$(MAKE)" -f "InitializingVariables.mk" 6 | clean: 7 | @echo "----------Cleaning project:[ InitializingVariables - Debug ]----------" 8 | @cd "InitializingVariables" && "$(MAKE)" -f "InitializingVariables.mk" clean 9 | -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_source_code/PrimitiveTypes/PrimitiveTypes.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_source_code/SizeofOperator/SizeofOperator.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_source_code/SizeofOperator/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section06-Variables_and_Constants/section06_source_code/SizeofOperator/main -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_source_code/SizeofOperator/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section06-Variables_and_Constants/section06_source_code/SizeofOperator/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section06-Variables_and_Constants/section06_source_code/SizeofOperator/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section07-Arrays_and_Vectors/section07_source_code/.codelite/Section7.session: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Section07-Arrays_and_Vectors/section07_source_code/.codelite/Section7.tags: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section07-Arrays_and_Vectors/section07_source_code/.codelite/Section7.tags -------------------------------------------------------------------------------- /Section07-Arrays_and_Vectors/section07_source_code/.codelite/compilation.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section07-Arrays_and_Vectors/section07_source_code/.codelite/compilation.db -------------------------------------------------------------------------------- /Section07-Arrays_and_Vectors/section07_source_code/.codelite/refactoring.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section07-Arrays_and_Vectors/section07_source_code/.codelite/refactoring.db -------------------------------------------------------------------------------- /Section07-Arrays_and_Vectors/section07_source_code/Arrays/Arrays.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section07-Arrays_and_Vectors/section07_source_code/Challenge/Challenge.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section07-Arrays_and_Vectors/section07_source_code/Challenge/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section07-Arrays_and_Vectors/section07_source_code/Challenge/main -------------------------------------------------------------------------------- /Section07-Arrays_and_Vectors/section07_source_code/Challenge/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section07-Arrays_and_Vectors/section07_source_code/Challenge/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section07-Arrays_and_Vectors/section07_source_code/Challenge/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section07-Arrays_and_Vectors/section07_source_code/ChallengeSolution/ChallengeSolution.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section07-Arrays_and_Vectors/section07_source_code/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean All 2 | 3 | All: 4 | @echo "----------Building project:[ Arrays - Debug ]----------" 5 | @cd "Arrays" && "$(MAKE)" -f "Arrays.mk" 6 | clean: 7 | @echo "----------Cleaning project:[ Arrays - Debug ]----------" 8 | @cd "Arrays" && "$(MAKE)" -f "Arrays.mk" clean 9 | -------------------------------------------------------------------------------- /Section07-Arrays_and_Vectors/section07_source_code/Section7.workspace: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Section07-Arrays_and_Vectors/section07_source_code/Vectors/Vectors.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section08-Statements_and_Operators/section08_source_code/.codelite/Section8.session: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Section08-Statements_and_Operators/section08_source_code/.codelite/Section8.tags: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section08-Statements_and_Operators/section08_source_code/.codelite/Section8.tags -------------------------------------------------------------------------------- /Section08-Statements_and_Operators/section08_source_code/.codelite/compilation.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section08-Statements_and_Operators/section08_source_code/.codelite/compilation.db -------------------------------------------------------------------------------- /Section08-Statements_and_Operators/section08_source_code/.codelite/refactoring.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section08-Statements_and_Operators/section08_source_code/.codelite/refactoring.db -------------------------------------------------------------------------------- /Section08-Statements_and_Operators/section08_source_code/ArithmeticOperators/ArithmeticOperators.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section08-Statements_and_Operators/section08_source_code/AssignmentOperator/AssignmentOperator.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section08-Statements_and_Operators/section08_source_code/AssignmentOperator/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 8 2 | // Assignment operator (=) 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | int main() { 9 | 10 | // variables initialization 11 | int num1 {10}; 12 | int num2 {20}; 13 | 14 | // assignment statement: 15 | num1 = 100; // assign 100 into num1 16 | // num1 = num2; // assign num2 value into num1 17 | // num1 = num2 = 1000; // works since compiler reads from right to left 18 | // num1 = "Frank"; // compiler will try to put string type into int type but will fail and output "conversion error" 19 | 20 | cout << "num1 is " << num1 << endl; 21 | cout << "num2 is " << num2 << endl; 22 | 23 | cout << endl; 24 | return 0; 25 | } 26 | 27 | /* 28 | int main() { 29 | 30 | // variables initialization 31 | const int num1 {10}; 32 | int num2 {20}; 33 | 34 | // num1 = 100; // this doesn't work because num1 is a constant, compiler will throw "read-only variable error" 35 | // 100 = num1; // compiler doesn't understand and throw error "lvalue required as left operand of assignment" 36 | 37 | cout << "num1 is " << num1 << endl; 38 | cout << "num2 is " << num2 << endl; 39 | 40 | cout << endl; 41 | return 0; 42 | } 43 | */ -------------------------------------------------------------------------------- /Section08-Statements_and_Operators/section08_source_code/Challenge/Challenge.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section08-Statements_and_Operators/section08_source_code/ChallengeSolution/ChallengeSolution.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section08-Statements_and_Operators/section08_source_code/EqualityOperators/EqualityOperators.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section08-Statements_and_Operators/section08_source_code/Euros/Euros.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section08-Statements_and_Operators/section08_source_code/Euros/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 8 2 | // Convert EUR to USD 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | int main() { 9 | 10 | const double usd_per_eur {1.19}; 11 | 12 | cout << "Welcome to the EUR to USD converter" << endl; 13 | cout << "Enter the value in EUR: "; 14 | 15 | double euros {0.0}; 16 | double dollars {0.0}; 17 | 18 | cin >> euros; 19 | dollars = euros * usd_per_eur; 20 | 21 | cout << euros << " euros is equivalent to " << dollars << " dollars" << endl; 22 | 23 | cout << endl; 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /Section08-Statements_and_Operators/section08_source_code/IncrementDecrementOperators/IncrementDecrementOperators.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section08-Statements_and_Operators/section08_source_code/LogicalOperators/LogicalOperators.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section08-Statements_and_Operators/section08_source_code/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean All 2 | 3 | All: 4 | @echo "----------Building project:[ AssignmentOperator - Debug ]----------" 5 | @cd "AssignmentOperator" && "$(MAKE)" -f "AssignmentOperator.mk" 6 | clean: 7 | @echo "----------Cleaning project:[ AssignmentOperator - Debug ]----------" 8 | @cd "AssignmentOperator" && "$(MAKE)" -f "AssignmentOperator.mk" clean 9 | -------------------------------------------------------------------------------- /Section08-Statements_and_Operators/section08_source_code/MixedExpressions/MixedExpressions.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section08-Statements_and_Operators/section08_source_code/MixedExpressions/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 8 2 | // Mixed Type Expressions 3 | /* 4 | Ask the user to enter 3 integers 5 | Calculate the sum of the integers then 6 | calculate the average of the 3 integers. 7 | 8 | Display the 3 integers entered 9 | the sum of the 3 integers and 10 | the average of the 3 integers. 11 | */ 12 | 13 | #include 14 | 15 | using namespace std; 16 | 17 | int main() { 18 | int total {}; 19 | int num1 {}, num2 {}, num3 {}; 20 | const int count {3}; 21 | 22 | cout << "Enter 3 integers separated by spaces: "; 23 | cin >> num1 >> num2 >> num3; 24 | 25 | total = num1 + num2 + num3; 26 | 27 | double average {0.0}; 28 | 29 | average = static_cast(total) / count; 30 | // average = (double)total/count; Old-Style 31 | 32 | 33 | cout << "The 3 numbers were: "<< num1 << ", " << num2 << ", " << num3 << endl; 34 | cout << "The sum of the numbers is: " << total << endl; 35 | cout << "The average of the numbers is: " << average << endl; 36 | 37 | cout << endl; 38 | return 0; 39 | } 40 | 41 | -------------------------------------------------------------------------------- /Section08-Statements_and_Operators/section08_source_code/RelationalOperators/RelationalOperators.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section08-Statements_and_Operators/section08_source_code/RelationalOperators/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 8 2 | // Relational Operators 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() { 8 | int num1{}, num2{}; 9 | 10 | cout << boolalpha; 11 | // cout << "Enter 2 integers separated by a space: "; 12 | // cin >> num1 >> num2; 13 | 14 | // cout << num1 << " > " << num2 << " : " << (num1 > num2) << endl; 15 | // cout << num1 << " >= " << num2 << " : " << (num1 >= num2) << endl; 16 | // cout << num1 << " < " << num2 << " : " << (num1 < num2) << endl; 17 | // cout << num1 << " <= " << num2 << " : " << (num1 <= num2) << endl; 18 | 19 | const int lower {10}; 20 | const int upper {20}; 21 | 22 | cout << "\nEnter an integer that is greater than " << lower << " : " ; 23 | cin >> num1; 24 | cout << num1 << " > " << lower << " is " << (num1 > lower) << endl; 25 | 26 | cout << "\nEnter an integer that is less than or equal to " << upper << " : " ; 27 | cin >> num1; 28 | cout << num1 << " <= " << upper << " is " << (num1 <= upper) << endl; 29 | 30 | cout << endl; 31 | return 0; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section09-Controlling_Program_Flow/.DS_Store -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section09-Controlling_Program_Flow/section09_source_code/.DS_Store -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/Challenge/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section09-Controlling_Program_Flow/section09_source_code/Challenge/main -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/Challenge/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/Challenge/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section09-Controlling_Program_Flow/section09_source_code/Challenge/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/ChallengeSolution/ChallengeSolution.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/ConditionalOperator/ConditionalOperator.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/ConditionalOperator/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 9 2 | // Conditional Operator 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() { 8 | 9 | // int num {}; 10 | // 11 | // cout << "Enter an integer: "; 12 | // cin >> num; 13 | // 14 | // if (num % 2 == 0) 15 | // cout << num << " is even" << endl; 16 | // else 17 | // cout << num << " is odd" << endl; 18 | // 19 | // cout << num << " is " << ( (num %2 ==0) ? "even" : "odd" ) << endl; 20 | 21 | int num1{}, num2{}; 22 | 23 | cout << "Enter two integers separated by a space: "; 24 | cin >> num1 >> num2; 25 | 26 | if (num1 != num2) { 27 | cout << "Largest: " << ( (num1 > num2) ? num1 : num2 ) << endl; 28 | cout << "Smallest: " << ( (num1 < num2) ? num1 : num2) << endl; 29 | 30 | } else { 31 | cout << "The numbers are the same" << endl; 32 | } 33 | 34 | cout << endl; 35 | return 0; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/DoWhile/DoWhile.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/DoWhile/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section09-Controlling_Program_Flow/section09_source_code/DoWhile/main -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/DoWhile/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 9 2 | // Do-while 3 | // Simple Menu Example 4 | #include 5 | 6 | 7 | using namespace std; 8 | 9 | int main() { 10 | 11 | char selection {}; 12 | do { 13 | cout << "\n---------------------" << endl; 14 | cout << "1. Do this" << endl; 15 | cout << "2. Do that" << endl; 16 | cout << "3. Do something else" << endl; 17 | cout << "Q. Quit" << endl; 18 | cout << "\nEnter your selection: "; 19 | cin >> selection; 20 | 21 | if (selection == '1') 22 | cout << "You chose 1 - doing this" << endl; 23 | else if (selection == '2') 24 | cout << "You chose 2 - doing that" << endl; 25 | else if (selection == '3') 26 | cout << "You chose 3 - doing something else" << endl; 27 | else if (selection == 'Q' || selection == 'q') 28 | cout << "Goodbye..." << endl; 29 | else 30 | cout << "Unknown option -- try again..." << endl; 31 | 32 | } while ( selection != 'q' && selection != 'Q'); // && instead of || under while loop so it doesn't keep running 33 | 34 | cout << endl; 35 | return 0; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/DoWhile/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/DoWhile/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section09-Controlling_Program_Flow/section09_source_code/DoWhile/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/ForLoop/ForLoop.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/ForLoop/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 9 2 | // For Loop 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | int main() { 9 | 10 | for (int i{1} ; i <=10 ; ++i) 11 | cout << i << endl; 12 | 13 | // for (int i{1} ; i <=10 ; i+=2) 14 | // cout << i << endl; 15 | 16 | // for (int i {10}; i > 0; --i) 17 | // cout << i << endl; 18 | // cout << "Blastoff!" << endl; 19 | 20 | // for (int i{10}; i<=100; i+=10) { 21 | // if (i % 15 == 0) 22 | // cout << i << endl; 23 | // } 24 | 25 | // for (int i{1}, j{5} ; i<=5 ; ++i, ++j) 26 | // cout << i << " + " << j << " = " << (i+j) << endl; 27 | 28 | // for ( int i{1}; i<=100; ++i) { 29 | // cout << i; 30 | // if (i % 5 ==0) 31 | // cout << endl; 32 | // else 33 | // cout << " "; 34 | // } 35 | // or 36 | // for (int i{1}; i <=100; ++i){ 37 | // cout << i; 38 | // cout << ( (i % 5 == 0) ? "\n" : " "); 39 | // } 40 | } 41 | // or 42 | // for ( int i{1}; i<=100; ++i) { 43 | // cout << i << ( (i % 10 ==0) ? "\n" : " "); 44 | // } 45 | // 46 | 47 | // vector nums { 10,20,30,40,50}; 48 | // for (unsigned i{0}; i< nums.size(); ++i) 49 | // cout << nums[i] << endl; 50 | 51 | 52 | cout << endl; 53 | return 0; 54 | } 55 | 56 | 57 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/Grades/Grades.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/Grades/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 9 2 | // Grades 3 | 4 | /* 5 | Calculate a sudent's grade on an exam given their score 6 | and tell them if they passed the course 7 | 8 | */ 9 | 10 | #include 11 | 12 | using namespace std; 13 | 14 | int main() { 15 | 16 | int score {}; 17 | cout << "Enter your score on the exam (0-100) : "; 18 | cin >> score; 19 | char letter_grade {}; 20 | 21 | if (score >= 0 && score <=100) { 22 | if (score >= 90) 23 | letter_grade = 'A'; 24 | else if (score >= 80) 25 | letter_grade = 'B'; 26 | else if (score >= 70) 27 | letter_grade = 'C'; 28 | else if (score >=60) 29 | letter_grade = 'D'; 30 | else 31 | letter_grade = 'F'; 32 | 33 | cout << "Your grade is : " << letter_grade << endl; 34 | if (letter_grade == 'F') 35 | cout << "Sorry, you must repeat the class" << endl; 36 | else 37 | cout << "Congrats!" << endl; 38 | 39 | } else { 40 | cout << "Sorry, " << score << " is not in range" << endl; 41 | } 42 | 43 | 44 | cout << endl; 45 | return 0; 46 | } 47 | 48 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/Histogram/Histogram.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/Histogram/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section09-Controlling_Program_Flow/section09_source_code/Histogram/main -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/Histogram/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 9 2 | // Nested Loops - Histogram 3 | 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | int main() { 10 | 11 | int num_items{}; 12 | 13 | cout << "How many data items do you have? "; 14 | cin >> num_items; 15 | 16 | vector data {}; 17 | 18 | for (int i{1}; i<= num_items; ++i) { 19 | int data_item{}; 20 | cout << "Enter data item " << i << ": "; 21 | cin >> data_item; 22 | data.push_back(data_item); 23 | } 24 | 25 | cout << "\nDisplaying Histogram" << endl; 26 | for (auto val: data) { 27 | for (int i{1} ; i<=val; ++i) { 28 | if (i % 5 == 0) 29 | cout << "*"; 30 | else 31 | cout << "-"; 32 | } 33 | cout << endl; 34 | } 35 | 36 | cout << endl; 37 | return 0; 38 | } 39 | 40 | 41 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/Histogram/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/Histogram/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section09-Controlling_Program_Flow/section09_source_code/Histogram/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/IfElseStatement/IfElseStatement.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/IfElseStatement/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 9 2 | // If-Else Statement 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() { 8 | int num{}; 9 | const int target {10}; 10 | 11 | cout << "Enter a number and I'll compare it to " << target << ": "; 12 | cin >> num; 13 | 14 | if (num >= target) { 15 | cout << "\n==================================" << endl; 16 | cout << num << " is greater than or equal to " << target << endl; 17 | int diff { num - target}; 18 | cout << num << " is " << diff << " greater than " << target << endl; 19 | } else { 20 | cout << "\n==================================" << endl; 21 | cout << num << " is less than " << target << endl; 22 | int diff { target - num}; 23 | cout << num << " is " << diff << " less than " << target << endl; 24 | } 25 | cout << endl; 26 | return 0; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/IfStatement/IfStatement.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean All 2 | 3 | All: 4 | @echo "----------Building project:[ SwitchEnum - Debug ]----------" 5 | @cd "SwitchEnum" && "$(MAKE)" -f "SwitchEnum.mk" 6 | clean: 7 | @echo "----------Cleaning project:[ SwitchEnum - Debug ]----------" 8 | @cd "SwitchEnum" && "$(MAKE)" -f "SwitchEnum.mk" clean 9 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/MultiplcationTable/MultiplcationTable.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/MultiplcationTable/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section09-Controlling_Program_Flow/section09_source_code/MultiplcationTable/main -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/MultiplcationTable/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 9 2 | // Nested Loops - Multiplication Table 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | int main() { 9 | 10 | for (int num1 {1}; num1 <=10 ; ++num1) { 11 | for (int num2 {1}; num2 <=10; ++num2) { 12 | cout << num1 << " * " << num2 << " = " << num1 * num2 << endl; 13 | } 14 | cout << "-----------" << endl; 15 | } 16 | 17 | cout << endl; 18 | return 0; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/MultiplcationTable/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/MultiplcationTable/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section09-Controlling_Program_Flow/section09_source_code/MultiplcationTable/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/RangeBasedForLoop/RangeBasedForLoop.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/Shipping/Shipping.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/Switch/Switch.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/SwitchEnum/SwitchEnum.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/SwitchEnum/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 9 2 | // Switch with enumeration 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | int main() { 9 | 10 | enum Direction { 11 | left, right, up, down 12 | }; 13 | 14 | Direction heading {left}; 15 | 16 | switch (heading) { 17 | case left: 18 | cout << "Going left" << endl; 19 | break; 20 | case right: 21 | cout << "Going right" << endl; // I used going left in the video by mistake 22 | break; 23 | default: 24 | cout << "OK" << endl; 25 | } 26 | 27 | cout << endl; 28 | return 0; 29 | } 30 | 31 | -------------------------------------------------------------------------------- /Section09-Controlling_Program_Flow/section09_source_code/WhileLoop/WhileLoop.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section10_Characters_and_Strings/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section10_Characters_and_Strings/.DS_Store -------------------------------------------------------------------------------- /Section10_Characters_and_Strings/section10_source_code/.codelite/Section10.session: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Section10_Characters_and_Strings/section10_source_code/.codelite/Section10.tags: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section10_Characters_and_Strings/section10_source_code/.codelite/Section10.tags -------------------------------------------------------------------------------- /Section10_Characters_and_Strings/section10_source_code/.codelite/compilation.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section10_Characters_and_Strings/section10_source_code/.codelite/compilation.db -------------------------------------------------------------------------------- /Section10_Characters_and_Strings/section10_source_code/.codelite/refactoring.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section10_Characters_and_Strings/section10_source_code/.codelite/refactoring.db -------------------------------------------------------------------------------- /Section10_Characters_and_Strings/section10_source_code/CPPStrings/CPPStrings.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section10_Characters_and_Strings/section10_source_code/CStyleStrings/CStyleStrings.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section10_Characters_and_Strings/section10_source_code/Challenge/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section10_Characters_and_Strings/section10_source_code/Challenge/main -------------------------------------------------------------------------------- /Section10_Characters_and_Strings/section10_source_code/Challenge/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section10_Characters_and_Strings/section10_source_code/Challenge/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section10_Characters_and_Strings/section10_source_code/Challenge/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section10_Characters_and_Strings/section10_source_code/ChallengeSolution/ChallengeSolution.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section10_Characters_and_Strings/section10_source_code/CharFunctions/CharFunctions.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section10_Characters_and_Strings/section10_source_code/CharFunctions/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | 8 | char str[] {"1234'5sddd'fdffg\n\t&^%23**~Frank Mary~ @!()-+=%^?<>;:"}; 9 | int num_letters {}; 10 | int num_digits {}; 11 | int num_whitespace {}; 12 | int num_punctuation {}; 13 | int num_others {}; 14 | 15 | for (char c: str) { 16 | if (isalpha(c)) 17 | num_letters++; 18 | else if (isdigit(c)) 19 | num_digits++; 20 | else if (isspace(c)) 21 | num_whitespace++; 22 | else if (ispunct(c)) 23 | num_punctuation++; 24 | else 25 | num_others++; 26 | } 27 | 28 | cout << "Letters : " << num_letters << endl; 29 | cout << "Digits: " << num_digits << endl; 30 | cout << "Whitespace: " << num_whitespace << endl; 31 | cout << "Punctuation: " << num_punctuation << endl; 32 | cout << "Others: " << num_others << endl; 33 | 34 | cout << endl; 35 | 36 | char str1 [] {"This is a test - 1 2 3"}; 37 | for (char c: str1) { 38 | cout << static_cast(toupper(c)); 39 | } 40 | cout << endl; 41 | 42 | return 0; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /Section10_Characters_and_Strings/section10_source_code/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean All 2 | 3 | All: 4 | @echo "----------Building project:[ CStyleStrings - Debug ]----------" 5 | @cd "CStyleStrings" && "$(MAKE)" -f "CStyleStrings.mk" 6 | clean: 7 | @echo "----------Cleaning project:[ CStyleStrings - Debug ]----------" 8 | @cd "CStyleStrings" && "$(MAKE)" -f "CStyleStrings.mk" clean 9 | -------------------------------------------------------------------------------- /Section11_Functions/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section11_Functions/.DS_Store -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/.codelite/Section11.session: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/.codelite/Section11.tags: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section11_Functions/section11_source_code/.codelite/Section11.tags -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/.codelite/compilation.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section11_Functions/section11_source_code/.codelite/compilation.db -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/.codelite/refactoring.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section11_Functions/section11_source_code/.codelite/refactoring.db -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/ArraysAndFunctions/ArraysAndFunctions.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/ArraysAndFunctions/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section11_Functions/section11_source_code/ArraysAndFunctions/main -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/ArraysAndFunctions/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 11 2 | // Arrays and functions 3 | #include 4 | 5 | using namespace std; 6 | 7 | // Function prototypes 8 | void print_array(const int arr[], size_t size); 9 | void set_array(int arr[], size_t size, int value); 10 | 11 | // Function print_array 12 | void print_array(const int arr[], size_t size) { // const 13 | for (size_t i{0}; i < size; ++i) 14 | cout << arr[i] << " "; 15 | cout << endl; 16 | // arr[0] = 50000; // bug 17 | } 18 | 19 | // Function set_array 20 | // set each array element to value 21 | void set_array(int arr[], size_t size, int value) { 22 | for (size_t i{0}; i < size; ++i) 23 | arr[i] = value; 24 | } 25 | 26 | int main() { 27 | int my_scores[] {100, 98, 90, 86, 84}; 28 | 29 | print_array(my_scores, 5); // goes to storage address instead of copying values 30 | set_array(my_scores, 5, 100); 31 | print_array(my_scores, 5); 32 | print_array(my_scores, 5); 33 | 34 | cout << endl; 35 | return 0; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/ArraysAndFunctions/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/ArraysAndFunctions/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section11_Functions/section11_source_code/ArraysAndFunctions/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/Challenge/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section11_Functions/section11_source_code/Challenge/main -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/Challenge/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/Challenge/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section11_Functions/section11_source_code/Challenge/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/ChallengeSolution/ChallengeSolution.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/DefaultArguments/DefaultArguments.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/Factorial/Factorial.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/Factorial/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 11 2 | // Recursion - Factorial 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | unsigned long long factorial(unsigned long long); 9 | 10 | unsigned long long factorial(unsigned long long n) { 11 | if (n == 0) 12 | return 1; // base case 13 | return n * factorial(n-1); // recursive case 14 | } 15 | 16 | int main() { 17 | cout << factorial(3) << endl; // 6 18 | // cout << factorial(8) << endl; // 40320 19 | // cout << factorial(12) << endl; // 479001600 20 | // cout << factorial(20) << endl; // 2432902008176640000 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/Fibonacci/Fibonacci.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/Fibonacci/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 11 2 | // Recursion - Fibonacci 3 | #include 4 | 5 | using namespace std; 6 | // Section 11 7 | // Recursion - Fibonacci 8 | 9 | #include 10 | 11 | using namespace std; 12 | unsigned long long fibonacci(unsigned long long n); 13 | 14 | unsigned long long fibonacci(unsigned long long n) { 15 | if (n <= 1) 16 | return n; // base cases 17 | return fibonacci(n-1) + fibonacci(n-2); // recursion 18 | } 19 | 20 | int main() { 21 | cout << fibonacci(5) << endl; // 5 22 | cout << fibonacci(30) << endl; // 832040  23 | cout << fibonacci(40) << endl; // 102334155 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/FunctionDefinitions/FunctionDefinitions.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/FunctionDefinitions/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 11 2 | // Function Definitions 3 | // Area of Circle and Volume of a Cylinder 4 | #include 5 | 6 | using namespace std; 7 | 8 | const double pi {3.14159}; 9 | 10 | // Function to calculate the area of a circle 11 | double calc_area_circle(double radius) { 12 | return pi * radius * radius; 13 | } 14 | 15 | // Function to calculate the volume of a cylinder 16 | double calc_volume_cylinder(double radius, double height) { 17 | // return pi * radius * radius * height; 18 | return calc_area_circle(radius) * height; 19 | } 20 | 21 | void area_circle() { 22 | double radius{}; 23 | cout << "\nEnter the radius of the circle: "; 24 | cin >> radius; 25 | cout << "The area of a circle with radius " << radius << " is " << calc_area_circle(radius) << endl; 26 | } 27 | 28 | void volume_cylinder() { 29 | double radius {}; 30 | double height {}; 31 | cout << "\nEnter the radius of the cylinder: "; 32 | cin >> radius; 33 | cout << "\nEnter the height of the cylinder: "; 34 | cin >> height; 35 | 36 | cout << "The volume of a cylinder with radius " << radius << " and height " << height << " is " << calc_volume_cylinder(radius, height) << endl; 37 | } 38 | 39 | int main() { 40 | 41 | area_circle(); 42 | area_circle(); 43 | volume_cylinder(); 44 | 45 | return 0; 46 | } 47 | 48 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/FunctionOverloading/FunctionOverloading.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/FunctionParamters/FunctionParameters.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/FunctionPrototypes/FunctionPrototypes.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/HowFunctionCallsWork/HowFunctionCallsWork.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/HowFunctionCallsWork/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section11_Functions/section11_source_code/HowFunctionCallsWork/main -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/HowFunctionCallsWork/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/HowFunctionCallsWork/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section11_Functions/section11_source_code/HowFunctionCallsWork/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean All 2 | 3 | All: 4 | @echo "----------Building project:[ Math - Debug ]----------" 5 | @cd "Math" && "$(MAKE)" -f "Math.mk" 6 | clean: 7 | @echo "----------Cleaning project:[ Math - Debug ]----------" 8 | @cd "Math" && "$(MAKE)" -f "Math.mk" clean 9 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/Math/Math.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/Math/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 11 2 | // Math examples 3 | 4 | #include 5 | #include // required 6 | 7 | using namespace std; 8 | 9 | int main() { 10 | 11 | double num {}; 12 | 13 | cout << "Enter a number (double) : "; 14 | cin >> num; 15 | 16 | cout << "The sqrt of " << num << " is: " << sqrt(num) << endl; 17 | cout << "The cubed root of " << num << " is: " << cbrt(num) << endl; 18 | 19 | cout << "The sine of " << num << " is: " << sin(num) << endl; 20 | cout << "The cosine of " << num << " is: " << cos(num) << endl; 21 | 22 | cout << "The ceil of " << num << " is: " << ceil(num) << endl; 23 | cout << "The floor of " << num << " is: " << floor(num) << endl; 24 | cout << "The round of " << num << " is: " << round(num) << endl; 25 | 26 | 27 | double power {}; 28 | cout << "\nEnter a power to raise " << num << " to: "; 29 | cin >> power; 30 | cout << num << " raised to the " << power << " power is: " << pow(num, power) << endl; 31 | // https://www.programiz.com/cpp-programming/library-function/cmath/pow 32 | // use pow function without knowing what it is doing in the back 33 | 34 | cout << endl; 35 | return 0; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/PassByReference/PassByReference.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/PassByReference/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section11_Functions/section11_source_code/PassByReference/main -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/PassByReference/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/PassByReference/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section11_Functions/section11_source_code/PassByReference/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/Random/Random.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/Random/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 11 2 | // Random Numbers 3 | 4 | #include 5 | #include // required for rand() 6 | // but there is also a random number generator library that could be more useful 7 | #include // required for time( ) 8 | 9 | using namespace std; 10 | 11 | int main() { 12 | 13 | int random_number {}; 14 | size_t count {10}; // number of random numbers to generate 15 | int min {1}; // lower bound (inclusive) 16 | int max {6}; // upper bound (inclusive) 17 | 18 | // seed the random number generator 19 | // If you don't seed the generator you will get the same requence random numbers every run 20 | 21 | cout << "RAND_MAX on my system is: " << RAND_MAX << endl; 22 | srand(time(nullptr)); // seed the random generator 23 | 24 | for (size_t i{1}; i<=count; ++i) { 25 | random_number = rand() % max + min; // generate a random number [min, max] 26 | cout << random_number << endl; 27 | } 28 | 29 | cout << endl; 30 | return 0; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/ScopeExample/ScopeExample.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/ScopeExample/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section11_Functions/section11_source_code/ScopeExample/main -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/ScopeExample/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section11_Functions/section11_source_code/ScopeExample/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section11_Functions/section11_source_code/ScopeExample/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/.DS_Store -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/.codelite/Section12.session: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/.codelite/Section12.tags: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/.codelite/Section12.tags -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/.codelite/compilation.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/.codelite/compilation.db -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/.codelite/cppcheck.list: -------------------------------------------------------------------------------- 1 | C:\Users\frank\Desktop\CPPExamples\Section12\ChallengeSolution\main.cpp 2 | C:\Users\frank\Desktop\CPPExamples\Section12\Debugger\main.cpp 3 | C:\Users\frank\Desktop\CPPExamples\Section12\Challenge\main.cpp 4 | C:\Users\frank\Desktop\CPPExamples\Section12\SimplePointers\main.cpp 5 | C:\Users\frank\Desktop\CPPExamples\Section12\Dereference\main.cpp 6 | C:\Users\frank\Desktop\CPPExamples\Section12\DynamicMemory\main.cpp 7 | C:\Users\frank\Desktop\CPPExamples\Section12\References\main.cpp 8 | C:\Users\frank\Desktop\CPPExamples\Section12\AraysAndPointers\main.cpp 9 | C:\Users\frank\Desktop\CPPExamples\Section12\PassingPointers2\main.cpp 10 | C:\Users\frank\Desktop\CPPExamples\Section12\PointerArithmetic\main.cpp 11 | C:\Users\frank\Desktop\CPPExamples\Section12\PassingPointers\main.cpp 12 | C:\Users\frank\Desktop\CPPExamples\Section12\PassingPointers3\main.cpp 13 | C:\Users\frank\Desktop\CPPExamples\Section12\ReturnPointer\main.cpp 14 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/.codelite/refactoring.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/.codelite/refactoring.db -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/AraysAndPointers/ArraysAndPointers.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/AraysAndPointers/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/AraysAndPointers/main -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/AraysAndPointers/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/AraysAndPointers/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/AraysAndPointers/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/Challenge/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/Challenge/main -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/Challenge/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/Challenge/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/Challenge/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/ChallengeSolution/ChallengeSolution.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/Debugger/Debugger.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/Debugger/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/Debugger/main -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/Debugger/main.cpp: -------------------------------------------------------------------------------- 1 | //Section 12 2 | // Debugger 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | void swap(int *a, int *b) { 9 | int temp = *a; 10 | *a = *b; 11 | *b = temp; 12 | } 13 | 14 | int main() { 15 | 16 | int i{5}; 17 | while (i>0) { 18 | cout << i << endl; 19 | i--; 20 | } 21 | 22 | int x {100}, y {200}; 23 | cout << "\nx: " << x << endl; 24 | cout << "y: " << y << endl; 25 | 26 | swap(&x, &y); 27 | 28 | cout << "\nx: " << x << endl; 29 | cout << "y: " << y << endl; 30 | cout << endl; 31 | return 0; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/Debugger/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/Debugger/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/Debugger/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/Dereference/Dereference.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/Dereference/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/Dereference/main -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/Dereference/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/Dereference/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/Dereference/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/DynamicMemory/DynamicMemory.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/DynamicMemory/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 12 2 | // Dynamic Memory 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() { 8 | 9 | int *int_ptr {nullptr}; 10 | int_ptr = new int; // allocate the int dynamically on the heap 11 | cout << int_ptr << endl; // Output: address in the heap 12 | // Can use int_ptr now 13 | delete int_ptr; // release it 14 | 15 | size_t size{0}; 16 | double *temp_ptr {nullptr}; 17 | 18 | cout << "How many temps? "; 19 | cin >> size; 20 | 21 | temp_ptr = new double[size]; // allocate the storage on the heap 22 | cout << temp_ptr << endl; // use it 23 | // Memory leak if temp_ptr = nullptr; 24 | // Now we lose the only way to access the memeory in the heap 25 | delete [] temp_ptr; // release it 26 | 27 | cout << endl; 28 | return 0; 29 | } 30 | 31 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean All 2 | 3 | All: 4 | @echo "----------Building project:[ SimplePointers - Debug ]----------" 5 | @cd "SimplePointers" && "$(MAKE)" -f "SimplePointers.mk" 6 | clean: 7 | @echo "----------Cleaning project:[ SimplePointers - Debug ]----------" 8 | @cd "SimplePointers" && "$(MAKE)" -f "SimplePointers.mk" clean 9 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/PassingPointers/PassingPointers.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/PassingPointers/PassingPointers1.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/PassingPointers/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/PassingPointers/main -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/PassingPointers/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 12 2 | // Passing Pointers 1 3 | #include 4 | 5 | using namespace std; 6 | 7 | 8 | void double_data(int *int_ptr) { 9 | *int_ptr *= 2; 10 | } 11 | 12 | int main() { 13 | int value {10}; 14 | int *int_ptr {nullptr}; 15 | 16 | cout << "Value: " << value << endl; // Output: 10 17 | double_data(&value); 18 | cout << "Value: " << value << endl; // Output: 20 19 | 20 | cout << "-----------------------------" << endl; 21 | int_ptr = &value; 22 | double_data(int_ptr); 23 | cout << "Value: " << value << endl; // Output: 40 24 | 25 | cout << endl; 26 | return 0; 27 | } -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/PassingPointers/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/PassingPointers/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/PassingPointers/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/PassingPointers2/PassingPointers2.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/PassingPointers2/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/PassingPointers2/main -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/PassingPointers2/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 12 2 | // Passing Pointers 2 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | 10 | void swap(int *a, int *b) { 11 | // a now has the address of x; b has the address of y 12 | // *a and *b derefernce the address and get the int values at the addresses respectively 13 | int temp = *a; // temp is an integer not a pointer 14 | // and temp is assigned with the dereferenced int value of address x == x value == 100 15 | *a = *b; // dereferncing a pointer and store the dereferenced b pointer value into the dereferenced a pointer == x 16 | // effectively: x = y 17 | *b = temp; // dereferncing b pointer and store the int value from variable temp 18 | } 19 | 20 | 21 | int main() { 22 | int x {100}, y {200}; 23 | cout << "\nx: " << x << endl; // Output: 100 24 | cout << "y: " << y << endl; // Output: 200 25 | 26 | swap(&x, &y); // pass in address of x and address of y as input to swap function 27 | 28 | cout << "\nx: " << x << endl; // Output: 200 29 | cout << "y: " << y << endl; // Output: 100 30 | 31 | cout << endl; 32 | return 0; 33 | } -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/PassingPointers2/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/PassingPointers2/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/PassingPointers2/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/PassingPointers3/PassingPointers3.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/PassingPointers3/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/PassingPointers3/main -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/PassingPointers3/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 12 2 | // Passing Pointers 3 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | 10 | void display( const vector *const v) { 11 | // (*v).at(0) = "Funny"; // this is not allowed anymore because of the const in front of vector in the function definition 12 | for (auto str: *v) 13 | cout << str << " "; 14 | cout << endl; 15 | 16 | // v = nullptr; // this is not allowed anymore because of the const in front of the pointer v and after the dereferencing operator * 17 | } 18 | 19 | void display(int *array, int sentinel) { 20 | while (*array != sentinel) 21 | cout << *array++ << " "; 22 | // can't have const pointer because *array++ is changing where the pointer is pointing at 23 | cout << endl; 24 | } 25 | 26 | int main() { 27 | 28 | // cout << "-----------------------------" << endl; 29 | // vector stooges {"Larry", "Moe", "Curly"}; 30 | // display(&stooges); 31 | 32 | cout << "\n-----------------------------" << endl; 33 | int scores[] {100,98,97,79,85,-1}; 34 | display(scores, -1); 35 | 36 | cout << endl; 37 | return 0; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/PassingPointers3/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/PassingPointers3/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/PassingPointers3/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/PointerArithmetic/PointerArithmetic.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/PointerArithmetic/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/PointerArithmetic/main -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/PointerArithmetic/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/PointerArithmetic/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/PointerArithmetic/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/References/References.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/References/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/References/main -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/References/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/References/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/References/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/ReturnPointer/ReturnPointer.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/ReturnPointer/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/ReturnPointer/main -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/ReturnPointer/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 12 2 | // Return Pointer 3 | #include 4 | 5 | using namespace std; 6 | 7 | int *create_array(size_t size, int init_value = 0) { 8 | int *new_storage {nullptr}; 9 | new_storage = new int[size]; // pointer to the heap 10 | for (size_t i{0}; i < size; ++i) 11 | *(new_storage + i) = init_value; // pointer offset notation 12 | // new_storage[i] = init_value; // pointer array notation 13 | return new_storage; 14 | } 15 | 16 | void display(const int *const array, size_t size) { 17 | for (size_t i{0}; i < size; ++i) 18 | cout << array[i] << " "; // pointer subscript notation 19 | cout << endl; 20 | } 21 | int main() { 22 | int *my_array {nullptr}; 23 | size_t size; 24 | int init_value {}; 25 | 26 | cout << "\nHow many integers would you like to allocate? "; 27 | cin >> size; 28 | cout << "What value would you like them initialized to? "; 29 | cin >> init_value; 30 | 31 | my_array = create_array(size, init_value); 32 | cout << "\n--------------------------------------" << endl; 33 | 34 | display(my_array, size); 35 | delete [] my_array; 36 | return 0; 37 | } -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/ReturnPointer/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/ReturnPointer/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/ReturnPointer/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/SimplePointers/SimplePointers.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/SimplePointers/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/SimplePointers/main -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/SimplePointers/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section12_Pointers_and_Reference/section12_source_code/SimplePointers/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section12_Pointers_and_Reference/section12_source_code/SimplePointers/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/.DS_Store -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/.DS_Store -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/.codelite/Section13.tags: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/.codelite/Section13.tags -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/.codelite/Section13.workspace.frank: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/.codelite/compilation.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/.codelite/compilation.db -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/.codelite/refactoring.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/.codelite/refactoring.db -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/AccessModifiers/AccessModifiers.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/AccessModifiers/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/AccessModifiers/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/AccessModifiers/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 13 2 | // Access Modifers 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | class Player { 9 | private: 10 | // attributes 11 | string name {"Player"}; 12 | int health; 13 | int xp; 14 | public: 15 | // methods 16 | void talk(string text_to_say) { cout << name << " says " << text_to_say << endl; } 17 | bool is_dead(); 18 | }; 19 | 20 | int main() { 21 | Player frank; 22 | // frank.name = "Frank"; // Compiler error 23 | // cout << frank.health << endl; // Compiler error 24 | frank.talk("Hello there"); 25 | return 0; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/AccessModifiers/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/AccessModifiers/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/AccessModifiers/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/AccessingClassMembers/AccessingClassMembers.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/AccessingClassMembers/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/AccessingClassMembers/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/AccessingClassMembers/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 13 2 | // Accessing Class Members 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | class Player { 9 | public: 10 | // attributes 11 | string name; 12 | int health; 13 | int xp; 14 | 15 | // methods 16 | void talk(string text_to_say) { cout << name << " says " << text_to_say << endl; } 17 | bool is_dead(); 18 | }; 19 | 20 | class Account { 21 | public: 22 | // attributes 23 | string name; 24 | double balance; 25 | 26 | // methods 27 | bool deposit(double bal) {balance += bal; cout << "In deposit" << endl; } 28 | bool withdraw(double bal) {balance -= bal; cout << "In withdraw" << endl; } 29 | 30 | }; 31 | 32 | int main() { 33 | Account frank_account; 34 | frank_account.name = "Frank's account"; 35 | frank_account.balance = 5000.0; 36 | 37 | frank_account.deposit(1000.0); 38 | frank_account.withdraw(500.0); 39 | 40 | 41 | Player frank; 42 | frank.name = "Frank"; 43 | frank.health = 100; 44 | frank.xp = 12; 45 | frank.talk("Hi there"); 46 | 47 | Player *enemy = new Player; 48 | (*enemy).name = "Enemy"; 49 | (*enemy).health = 100; 50 | enemy->xp = 15; 51 | 52 | enemy->talk("I will destroy you!"); 53 | 54 | 55 | 56 | return 0; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/AccessingClassMembers/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/AccessingClassMembers/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/AccessingClassMembers/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/Challenge/Movie.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************** 2 | * Section 13 Challenge 3 | * Movie.cpp 4 | * 5 | * Models a Movie with the following atttributes 6 | * 7 | * std::string name - the name of the movie 8 | * std::string rating - G, PG, PG-13, R 9 | * int watched - the number of times you've watched the movie 10 | * ***************************************************************/ 11 | #include 12 | #include "Movie.h" 13 | 14 | // Implemention of the construcor 15 | 16 | Movie::Movie(std::string name, std::string rating, int watched) 17 | : name(name), rating(rating), watched(watched) { 18 | } 19 | 20 | //Implemention of the copy constructor 21 | Movie::Movie(const Movie &source) 22 | : Movie{source.name, source.rating, source.watched} { 23 | } 24 | 25 | // Implementation of the destructor 26 | Movie::~Movie() { 27 | } 28 | 29 | // Implementation of the display method 30 | // should just insert the movie attributes to cout 31 | 32 | void Movie::display() const { 33 | std::cout << name << ", " << rating << ", " << watched << std::endl; 34 | } 35 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/Challenge/Movies.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.Movies 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/Challenge/Movies.dSYM/Contents/Resources/DWARF/Movies: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/Challenge/Movies.dSYM/Contents/Resources/DWARF/Movies -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/Challenge/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/Challenge/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/Challenge/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/Challenge/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/Challenge/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ChallengeSolution/ChallengeSolution.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o ./Debug/Movie.cpp.o ./Debug/Movies.cpp.o 2 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ChallengeSolution/Movie.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************** 2 | * Section 13 Challenge Solution 3 | * Movie.cpp 4 | * 5 | * Models a Movie with the following atttributes 6 | * 7 | * std::string name - the name of the movie 8 | * std::string rating - G, PG, PG-13, R 9 | * int watched - the number of times you've watched the movie 10 | * ***************************************************************/ 11 | #include 12 | #include "Movie.h" 13 | 14 | // Implemention of the construcor 15 | 16 | Movie::Movie(std::string name, std::string rating, int watched) 17 | : name(name), rating(rating), watched(watched) { 18 | } 19 | 20 | //Implemention of the copy constructor 21 | Movie::Movie(const Movie &source) 22 | : Movie{source.name, source.rating, source.watched} { 23 | } 24 | 25 | // Implementation of the destructor 26 | Movie::~Movie() { 27 | } 28 | 29 | // Implementation of the display method 30 | // should just insert the movie attributes to cout 31 | 32 | void Movie::display() const { 33 | std::cout << name << ", " << rating << ", " << watched << std::endl; 34 | } 35 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ChallengeSolution/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/ChallengeSolution/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ChallengeSolution/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ChallengeSolution/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/ChallengeSolution/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ConstInClasses/ConstInClasses.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ConstInClasses/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 13 2 | // Const in Classes 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | class Player 9 | { 10 | private: 11 | std::string name; 12 | int health; 13 | int xp; 14 | public: 15 | std::string get_name() const { // consty method 16 | return name; 17 | } 18 | void set_name(std::string name_val) { 19 | name = name_val; 20 | } 21 | // Overloaded Constructors 22 | Player(); 23 | Player(std::string name_val); 24 | Player(std::string name_val, int health_val, int xp_val); 25 | }; 26 | 27 | Player::Player() 28 | : Player {"None",0,0} { 29 | } 30 | 31 | Player::Player(std::string name_val) 32 | : Player {name_val,0, 0} { 33 | } 34 | 35 | Player::Player(std::string name_val, int health_val, int xp_val) 36 | : name{name_val}, health{health_val}, xp{xp_val} { 37 | } 38 | 39 | void display_player_name(const Player &p) { 40 | cout << p.get_name() << endl; 41 | } 42 | 43 | int main() { 44 | 45 | const Player villain {"Villain", 100, 55}; 46 | Player hero {"Hero", 100, 15}; 47 | 48 | // villain.set_name("Super villain"); 49 | cout << villain.get_name() << endl; 50 | cout << hero.get_name() << endl; 51 | 52 | display_player_name(villain); 53 | display_player_name(hero); 54 | 55 | 56 | 57 | return 0; 58 | } 59 | 60 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ConstructorInitializationLists/ConstructorInitializationLists.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ConstructorInitializationLists/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 13 2 | // Constructor Initialization Lists 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | class Player 9 | { 10 | private: 11 | std::string name {"XXXXXXX"}; 12 | int health; 13 | int xp; 14 | public: 15 | // Overloaded Constructors 16 | Player(); 17 | Player(std::string name_val); 18 | Player(std::string name_val, int health_val, int xp_val); 19 | }; 20 | 21 | Player::Player() 22 | : name{"None"}, health{0}, xp{0} { 23 | // // Previously 24 | // name = "None"; 25 | // health = 0; 26 | // xp = 0; 27 | } 28 | 29 | Player::Player(std::string name_val) 30 | : name{name_val}, health{0}, xp{0} { 31 | // // Previously 32 | // name = name_val; 33 | // health = 0; 34 | // xp = 0; 35 | } 36 | 37 | Player::Player(std::string name_val, int health_val, int xp_val) 38 | : name{name_val}, health{health_val}, xp{xp_val} { 39 | // // Previously 40 | // name = name_val; 41 | // health = health_val; 42 | // xp = xp_val; 43 | } 44 | 45 | int main() { 46 | 47 | Player empty; 48 | Player frank {"Frank"}; 49 | Player villain {"Villain", 100, 55}; 50 | 51 | return 0; 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ConstructorsAndDestructors/ConstructorsAndDestructors.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ConstructorsAndDestructors/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/ConstructorsAndDestructors/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ConstructorsAndDestructors/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ConstructorsAndDestructors/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/ConstructorsAndDestructors/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/CopyConstructor/CopyConstructor.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/DeclareClassAndObjects/DeclareClassAndObjects.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/DeclareClassAndObjects/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/DeclareClassAndObjects/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/DeclareClassAndObjects/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 13 2 | // Declare Classes and Objects 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | class Player { 10 | // attributes 11 | string name {"Player"}; 12 | int health {100}; 13 | int xp {3}; 14 | 15 | // methods 16 | void talk(string); 17 | bool is_dead(); 18 | }; 19 | 20 | class Account { 21 | // attributes 22 | string name {"Account"}; 23 | double balance {0.0}; 24 | 25 | // methods 26 | bool deposit(double); 27 | bool withdraw(double); 28 | 29 | }; 30 | 31 | 32 | int main() { 33 | Account frank_account; 34 | Account jim_account; 35 | 36 | 37 | Player frank; 38 | Player hero; 39 | 40 | Player players[] {frank, hero}; 41 | 42 | vector player_vec {frank}; 43 | player_vec.push_back(hero); 44 | 45 | 46 | Player *enemy {nullptr}; 47 | enemy = new Player; 48 | 49 | delete enemy; 50 | 51 | return 0; 52 | } -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/DeclareClassAndObjects/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/DeclareClassAndObjects/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/DeclareClassAndObjects/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/DeepCopy/DeepCopy.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/DeepCopy/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 13 2 | // Copy Constructor - Deep Copy 3 | #include 4 | 5 | using namespace std; 6 | 7 | class Deep { 8 | private: 9 | int *data; 10 | public: 11 | void set_data_value(int d) { *data = d; } 12 | int get_data_value() { return *data; } 13 | // Constructor 14 | Deep(int d); 15 | // Copy Constructor 16 | Deep(const Deep &source); 17 | // Destructor 18 | ~Deep(); 19 | }; 20 | 21 | // Constructor 22 | Deep::Deep(int d) { 23 | data = new int; 24 | *data = d; 25 | } 26 | 27 | // Deep copy Constructor 28 | Deep::Deep(const Deep &source) 29 | : Deep {*source.data} { 30 | cout << "Copy constructor - deep copy" << endl; 31 | } 32 | 33 | // Destructor 34 | Deep::~Deep() { 35 | delete data; 36 | cout << "Destructor freeing data" << endl; 37 | } 38 | 39 | void display_deep(Deep s) { 40 | cout << s.get_data_value() << endl; 41 | } 42 | 43 | int main() { 44 | 45 | Deep obj1 {100}; 46 | display_deep(obj1); 47 | 48 | Deep obj2 {obj1}; 49 | 50 | obj2.set_data_value(1000); 51 | 52 | return 0; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/DefaultConstructor/DefaultConstructor.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/DefaultConstructor/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/DefaultConstructor/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/DefaultConstructor/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 13 2 | // Default Constructors 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | class Player 9 | { 10 | private: 11 | std::string name; 12 | int health; 13 | int xp; 14 | public: 15 | 16 | // no consturctor declared 17 | // so C++ will default no-args constructors 18 | 19 | void set_name(std::string name_val) { 20 | name = name_val; 21 | } 22 | std::string get_name() { 23 | return name; 24 | } 25 | 26 | // Declare a constructor 27 | Player() { 28 | name = "None"; 29 | health = 100; 30 | xp = 3; 31 | } 32 | 33 | // Overloaded constructor 34 | Player(std::string name_val, int health_val, int xp_val) { 35 | name = name_val; 36 | health = health_val; 37 | xp = xp_val; 38 | } 39 | 40 | }; 41 | 42 | int main() { 43 | Player hero; 44 | Player frank {"Frank", 100, 13}; 45 | frank.set_name("Frank"); 46 | cout << frank.get_name() << endl; 47 | return 0; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/DefaultConstructor/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/DefaultConstructor/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/DefaultConstructor/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/DefaultConstructorParameters/DefaultConstructorParameters.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/DefaultConstructorParameters/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 13 2 | // Default Constructor Parameters 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | class Player 9 | { 10 | private: 11 | std::string name; 12 | int health; 13 | int xp; 14 | public: 15 | Player(std::string name_val ="None", int health_val = 0, int xp_val = 0); 16 | // Player() {} // Will cause a compiler error 17 | }; 18 | 19 | 20 | Player::Player(std::string name_val, int health_val, int xp_val) 21 | : name{name_val}, health{health_val}, xp{xp_val} { 22 | cout << "Three-args constructor" << endl; 23 | } 24 | 25 | 26 | int main() { 27 | 28 | Player empty; 29 | Player frank {"Frank"}; 30 | Player hero {"Hero", 100}; 31 | Player villain {"Villain", 100, 55}; 32 | 33 | return 0; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/DelegatingConstructors/DelegatingConstructors.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/DelegatingConstructors/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 13 2 | // Delegating Constructors 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | class Player 9 | { 10 | private: 11 | std::string name; 12 | int health; 13 | int xp; 14 | public: 15 | // Overloaded Constructors 16 | Player(); 17 | Player(std::string name_val); 18 | Player(std::string name_val, int health_val, int xp_val); 19 | }; 20 | 21 | Player::Player() 22 | : Player {"None",0,0} { 23 | cout << "No-args constructor" << endl; 24 | } 25 | 26 | Player::Player(std::string name_val) 27 | : Player {name_val,0, 0} { 28 | cout << "One-arg constructor" << endl; 29 | } 30 | 31 | Player::Player(std::string name_val, int health_val, int xp_val) 32 | : name{name_val}, health{health_val}, xp{xp_val} { 33 | cout << "Three-args constructor" << endl; 34 | } 35 | 36 | int main() { 37 | 38 | Player empty; 39 | Player frank {"Frank"}; 40 | Player villain {"Villain", 100, 55}; 41 | 42 | return 0; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/Friends/Friend_class.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Friend_class.h" 3 | 4 | class Player; 5 | void Friend_class::set_hero_name(Player &p, std::string name) { 6 | p.name = name; 7 | } 8 | 9 | void Friend_class::display_player(Player &p) { 10 | std::cout << p.name << std::endl; 11 | std::cout << p.health << std::endl; 12 | std::cout << p.xp << std::endl; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/Friends/Friend_class.h: -------------------------------------------------------------------------------- 1 | #ifndef _FRIEND_CLASS_H_ 2 | #define _FRIEND_CLASS_H_ 3 | #include 4 | #include "Player.h" 5 | 6 | class Friend_class 7 | { 8 | public: 9 | void set_hero_name(Player &p, std::string name); 10 | void display_player(Player &p); 11 | }; 12 | 13 | #endif // _FRIEND_CLASS_H_ 14 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/Friends/Friends.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o ./Debug/Player.cpp.o ./Debug/Other_class.cpp.o ./Debug/Friend_class.cpp.o 2 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/Friends/Other_class.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Other_class.h" 3 | #include "Player.h" 4 | 5 | void Other_class::display_player(Player &p) { 6 | std::cout << p.name << std::endl; 7 | std::cout << p.health << std::endl; 8 | std::cout << p.xp << std::endl; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/Friends/Other_class.h: -------------------------------------------------------------------------------- 1 | #ifndef _OTHER_CLASS_H_ 2 | #define _OTHER_CLASS_H_ 3 | 4 | class Player; 5 | 6 | class Other_class 7 | { 8 | public: 9 | void display_player(Player &p); 10 | }; 11 | 12 | #endif // _OTHER_CLASS_H_ 13 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/Friends/Player.cpp: -------------------------------------------------------------------------------- 1 | #include "Player.h" 2 | 3 | int Player::num_players {0}; 4 | 5 | Player::Player(std::string name_val, int health_val, int xp_val) 6 | : name{name_val}, health{health_val}, xp{xp_val} { 7 | ++num_players; 8 | } 9 | 10 | Player::Player(const Player &source) 11 | : Player {source.name, source.health, source.xp} { 12 | } 13 | 14 | Player::~Player() { 15 | --num_players; 16 | } 17 | 18 | int Player::get_num_players() { 19 | return num_players; 20 | } 21 | 22 | 23 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/Friends/Player.h: -------------------------------------------------------------------------------- 1 | #ifndef _PLAYER_H_ 2 | #define _PLAYER_H_ 3 | #include 4 | 5 | #include "Other_class.h" 6 | class Friend_class; 7 | 8 | class Player { 9 | friend void Other_class::display_player(Player &p); 10 | friend void display_player(Player &p); 11 | friend class Friend_class; 12 | private: 13 | static int num_players; 14 | std::string name; 15 | int health; 16 | int xp; 17 | public: 18 | std::string get_name() { return name; } 19 | int get_health() { return health; } 20 | int get_xp() {return xp; } 21 | Player(std::string name_val ="None", int health_val = 0, int xp_val = 0); 22 | // Copy constructor 23 | Player(const Player &source); 24 | // Destructor 25 | ~Player(); 26 | 27 | static int get_num_players(); 28 | 29 | }; 30 | 31 | #endif // _PLAYER_H_ 32 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/Friends/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "Player.h" 4 | #include "Other_class.h" 5 | #include "Friend_class.h" 6 | 7 | void display_player(Player &p) { 8 | std::cout << p.name << std::endl; 9 | std::cout << p.health << std::endl; 10 | std::cout << p.xp << std::endl; 11 | } 12 | 13 | using namespace std; 14 | 15 | int main() { 16 | 17 | Player hero{"Hero", 100, 35}; 18 | display_player(hero); 19 | 20 | Other_class other; 21 | other.display_player(hero); 22 | 23 | Friend_class friend_class; 24 | friend_class.set_hero_name(hero,"SUPER HERO"); 25 | friend_class.display_player(hero); 26 | 27 | return 0; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ImplementingMethods/ImplementingMethods1.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ImplementingMethods/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/ImplementingMethods/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ImplementingMethods/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ImplementingMethods/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/ImplementingMethods/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ImplementingMethods2/Account.cpp: -------------------------------------------------------------------------------- 1 | #include "Account.h" 2 | 3 | void Account::set_name(std::string n) { 4 | name = n; 5 | } 6 | 7 | std::string Account::get_name() { 8 | return name; 9 | } 10 | 11 | bool Account::deposit(double amount) { 12 | // if verify amount 13 | balance += amount; 14 | return true; 15 | } 16 | 17 | bool Account::withdraw(double amount) { 18 | if (balance-amount >= 0) { 19 | balance -= amount; 20 | return true; 21 | } else { 22 | return false; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ImplementingMethods2/Account.h: -------------------------------------------------------------------------------- 1 | #ifndef _ACCOUNT_H_ 2 | #define _ACCOUNT_H_ 3 | #include 4 | 5 | class Account { 6 | private: 7 | // attributes 8 | std::string name; 9 | double balance; 10 | 11 | public: 12 | // methods 13 | // declared inline 14 | void set_balance(double bal) { balance = bal; } 15 | double get_balance() { return balance; } 16 | 17 | // methods will be declared outside the class declaration 18 | void set_name(std::string n); 19 | std::string get_name(); 20 | 21 | bool deposit(double amount); 22 | bool withdraw(double amount); 23 | }; 24 | 25 | #endif // _ACCOUNT_H_ 26 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ImplementingMethods2/ImplementingMethods2.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o ./Debug/Account.cpp.o 2 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ImplementingMethods2/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/ImplementingMethods2/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ImplementingMethods2/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 13 2 | // Implementing member methods 2 3 | #include 4 | #include "Account.h" 5 | 6 | using namespace std; 7 | 8 | int main() { 9 | Account frank_account; 10 | frank_account.set_name("Frank's account"); 11 | frank_account.set_balance(1000.0); 12 | 13 | if (frank_account.deposit(200.0)) 14 | cout << "Deposit OK" << endl; 15 | else 16 | cout << "Deposit Not allowed" << endl; 17 | 18 | if (frank_account.withdraw(500.0)) 19 | cout << "Withdrawal OK" << endl; 20 | else 21 | cout << "Not sufficient funds" << endl; 22 | 23 | if (frank_account.withdraw(1500.0)) 24 | cout << "Withdraw OK" << endl; 25 | else 26 | cout << "Not sufficient funds" << endl; 27 | 28 | return 0; 29 | } 30 | 31 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ImplementingMethods2/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ImplementingMethods2/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/ImplementingMethods2/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean All 2 | 3 | All: 4 | @echo "----------Building project:[ DeclareClassAndObjects - Debug ]----------" 5 | @cd "DeclareClassAndObjects" && "$(MAKE)" -f "DeclareClassAndObjects.mk" 6 | clean: 7 | @echo "----------Cleaning project:[ DeclareClassAndObjects - Debug ]----------" 8 | @cd "DeclareClassAndObjects" && "$(MAKE)" -f "DeclareClassAndObjects.mk" clean 9 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/MoveConstructor/MoveConstructor.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/MoveConstructor/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/MoveConstructor/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/MoveConstructor/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/MoveConstructor/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/MoveConstructor/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ShallowCopy/ShallowCopy.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o 2 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ShallowCopy/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/ShallowCopy/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ShallowCopy/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/ShallowCopy/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/ShallowCopy/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/StaticClassMembers/Player.cpp: -------------------------------------------------------------------------------- 1 | #include "Player.h" 2 | 3 | // initialize static variable 4 | int Player::num_players {0}; 5 | 6 | Player::Player(std::string name_val, int health_val, int xp_val) 7 | : name{name_val}, health{health_val}, xp{xp_val} { 8 | ++num_players; 9 | } 10 | 11 | Player::Player(const Player &source) 12 | : Player {source.name, source.health, source.xp} { 13 | } 14 | 15 | Player::~Player() { 16 | --num_players; 17 | } 18 | 19 | // static function implementation 20 | int Player::get_num_players() { 21 | return num_players; 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/StaticClassMembers/Player.h: -------------------------------------------------------------------------------- 1 | #ifndef _PLAYER_H_ 2 | #define _PLAYER_H_ 3 | #include 4 | 5 | class Player 6 | { 7 | private: 8 | static int num_players; 9 | std::string name; 10 | int health; 11 | int xp; 12 | public: 13 | std::string get_name() { return name; } 14 | int get_health() { return health; } 15 | int get_xp() {return xp; } 16 | Player(std::string name_val ="None", int health_val = 0, int xp_val = 0); 17 | // Copy constructor 18 | Player(const Player &source); 19 | // Destructor 20 | ~Player(); 21 | 22 | static int get_num_players(); 23 | // static functions are class functions. 24 | // - only have access to static variables 25 | // - do not have access to i.e. name, health, xp 26 | 27 | }; 28 | 29 | #endif // _PLAYER_H_ 30 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/StaticClassMembers/StaticClassMembers.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o ./Debug/Player.cpp.o 2 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/StaticClassMembers/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/StaticClassMembers/main -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/StaticClassMembers/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 13 2 | // Static class members 3 | #include 4 | #include "Player.h" 5 | 6 | using namespace std; 7 | 8 | // helper function 9 | void display_active_players() { 10 | cout << "Active players: " << Player::get_num_players() << endl; 11 | } 12 | 13 | int main() { 14 | display_active_players(); // Output: 0 15 | Player hero{"Hero"}; 16 | display_active_players(); // Output: 1 17 | 18 | { 19 | Player frank{"Frank"}; 20 | display_active_players(); // Output: 2 21 | } 22 | display_active_players(); // Output: 1 23 | 24 | Player *enemy = new Player("Enemy", 100, 100); 25 | display_active_players(); // Output: 2 26 | delete enemy; 27 | display_active_players(); // Output: 1 28 | 29 | 30 | 31 | return 0; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/StaticClassMembers/main.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.main 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section13_OOP-Classes_and_Objects/section13_source_code/StaticClassMembers/main.dSYM/Contents/Resources/DWARF/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section13_OOP-Classes_and_Objects/section13_source_code/StaticClassMembers/main.dSYM/Contents/Resources/DWARF/main -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/.codelite/Section14.tags: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section14-OperatorOverloading/section14_source_code/.codelite/Section14.tags -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/.codelite/Section14.workspace.frank: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/.codelite/compilation.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section14-OperatorOverloading/section14_source_code/.codelite/compilation.db -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/.codelite/refactoring.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section14-OperatorOverloading/section14_source_code/.codelite/refactoring.db -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/Challenge-Solution1/Challenge-Solution1.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o ./Debug/Mystring.cpp.o 2 | -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/Challenge-Solution2/Challenge-Solution2.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o ./Debug/Mystring.cpp.o 2 | -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/Challenge/Challenge.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o ./Debug/Mystring.cpp.o 2 | -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/Challenge/Mystring.h: -------------------------------------------------------------------------------- 1 | #ifndef _MYSTRING_H_ 2 | #define _MYSTRING_H_ 3 | 4 | class Mystring 5 | { 6 | friend std::ostream &operator<<(std::ostream &os, const Mystring &rhs); 7 | friend std::istream &operator>>(std::istream &in, Mystring &rhs); 8 | 9 | private: 10 | char *str; // pointer to a char[] that holds a C-style string 11 | public: 12 | Mystring(); // No-args constructor 13 | Mystring(const char *s); // Overloaded constructor 14 | Mystring(const Mystring &source); // Copy constructor 15 | Mystring( Mystring &&source); // Move constructor 16 | ~Mystring(); // Destructor 17 | 18 | Mystring &operator=(const Mystring &rhs); // Copy assignment 19 | Mystring &operator=(Mystring &&rhs); // Move assignment 20 | 21 | void display() const; 22 | 23 | int get_length() const; // getters 24 | const char *get_str() const; 25 | }; 26 | 27 | #endif // _MYSTRING_H_ -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean All 2 | 3 | All: 4 | @echo "----------Building project:[ Mystring-operator-methods - Debug ]----------" 5 | @cd "Mystring-operators" && "$(MAKE)" -f "Mystring-operator-methods.mk" 6 | clean: 7 | @echo "----------Cleaning project:[ Mystring-operator-methods - Debug ]----------" 8 | @cd "Mystring-operators" && "$(MAKE)" -f "Mystring-operator-methods.mk" clean 9 | -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/Mystring-copy-assignment/Mystring-copy-assignment.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o ./Debug/Mystring.cpp.o 2 | -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/Mystring-copy-assignment/Mystring.h: -------------------------------------------------------------------------------- 1 | #ifndef _MYSTRING_H_ 2 | #define _MYSTRING_H_ 3 | 4 | class Mystring 5 | { 6 | private: 7 | char *str; // pointer to a char[] that holds a C-style string 8 | public: 9 | Mystring(); // No-args constructor 10 | Mystring(const char *s); // Overloaded constructor 11 | Mystring(const Mystring &source); // Copy constructor 12 | ~Mystring(); // Destructor 13 | 14 | Mystring &operator=(const Mystring &rhs); // Copy assignment 15 | 16 | void display() const; 17 | 18 | int get_length() const; // getters 19 | const char *get_str() const; 20 | }; 21 | 22 | #endif // _MYSTRING_H_ 23 | -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/Mystring-insertion-extraction/Mystring-insertion-extraction.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o ./Debug/Mystring.cpp.o 2 | -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/Mystring-insertion-extraction/Mystring.h: -------------------------------------------------------------------------------- 1 | #ifndef _MYSTRING_H_ 2 | #define _MYSTRING_H_ 3 | 4 | class Mystring 5 | { 6 | friend std::ostream &operator<<(std::ostream &os, const Mystring &rhs); 7 | friend std::istream &operator>>(std::istream &in, Mystring &rhs); 8 | 9 | private: 10 | char *str; // pointer to a char[] that holds a C-style string 11 | public: 12 | Mystring(); // No-args constructor 13 | Mystring(const char *s); // Overloaded constructor 14 | Mystring(const Mystring &source); // Copy constructor 15 | Mystring( Mystring &&source); // Move constructor 16 | ~Mystring(); // Destructor 17 | 18 | Mystring &operator=(const Mystring &rhs); // Copy assignment 19 | Mystring &operator=(Mystring &&rhs); // Move assignment 20 | 21 | void display() const; 22 | 23 | int get_length() const; // getters 24 | const char *get_str() const; 25 | }; 26 | 27 | #endif // _MYSTRING_H_ -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/Mystring-insertion-extraction/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 14 2 | // Overloaded insertion and extraction operators 3 | #include 4 | #include "Mystring.h" 5 | 6 | using namespace std; 7 | 8 | int main() { 9 | 10 | Mystring larry {"Larry"}; 11 | Mystring moe {"Moe"}; 12 | Mystring curly; 13 | 14 | cout << "Enter the third stooge's first name: "; 15 | cin >> curly; 16 | 17 | cout << "The three stooges are " << larry << ", " << moe << ", and " << curly << endl; 18 | 19 | cout << "\nEnter the three stooges names separated by a space: "; 20 | cin >> larry >> moe >> curly; 21 | 22 | cout << "The three stooges are " << larry << ", " << moe << ", and " << curly << endl; 23 | 24 | return 0; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/Mystring-move-assignment/Mystring-move-assignment.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o ./Debug/Mystring.cpp.o 2 | -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/Mystring-move-assignment/Mystring.h: -------------------------------------------------------------------------------- 1 | #ifndef _MYSTRING_H_ 2 | #define _MYSTRING_H_ 3 | 4 | class Mystring 5 | { 6 | private: 7 | char *str; // pointer to a char[] that holds a C-style string 8 | public: 9 | Mystring(); // No-args constructor 10 | Mystring(const char *s); // Overloaded constructor 11 | Mystring(const Mystring &source); // Copy constructor 12 | Mystring( Mystring &&source); // Move constructor 13 | ~Mystring(); // Destructor 14 | 15 | Mystring &operator=(const Mystring &rhs); // Copy assignment 16 | Mystring &operator=(Mystring &&rhs); // Move assignment 17 | 18 | void display() const; 19 | 20 | int get_length() const; // getters 21 | const char *get_str() const; 22 | }; 23 | 24 | #endif // _MYSTRING_H_ 25 | -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/Mystring-operator-functions/Mystring-operator-functions.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o ./Debug/Mystring.cpp.o 2 | -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/Mystring-operator-functions/Mystring.h: -------------------------------------------------------------------------------- 1 | #ifndef _MYSTRING_H_ 2 | #define _MYSTRING_H_ 3 | 4 | class Mystring { 5 | friend bool operator==(const Mystring &lhs, const Mystring &rhs); 6 | friend Mystring operator-(const Mystring &obj); 7 | friend Mystring operator+(const Mystring &lhs, const Mystring &rhs); 8 | private: 9 | char *str; // pointer to a char[] that hold a C-style string 10 | public: 11 | Mystring(); 12 | Mystring(const char *s); 13 | Mystring(const Mystring &source); 14 | Mystring( Mystring &&source); 15 | ~Mystring(); 16 | 17 | Mystring &operator=(const Mystring &rhs); 18 | Mystring &operator=(Mystring &&rhs); 19 | 20 | void display() const; 21 | 22 | int get_length() const; 23 | const char *get_str() const; 24 | }; 25 | 26 | #endif // _MYSTRING_H_ 27 | -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/Mystring-operator-functions/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 14 2 | // Overloading operators as non-member (global) methods 3 | #include 4 | #include 5 | #include "Mystring.h" 6 | 7 | using namespace std; 8 | 9 | int main() { 10 | 11 | Mystring larry {"Larry"}; 12 | larry.display(); // Larry 13 | 14 | larry = -larry; 15 | larry.display(); // larry 16 | 17 | cout << boolalpha << endl; 18 | Mystring moe{"Moe"}; 19 | Mystring stooge = larry; 20 | 21 | cout << (larry == moe) << endl; // false 22 | cout << (larry == stooge) << endl; // true 23 | 24 | // Mystring stooges = larry + "Moe"; 25 | Mystring stooges = "Larry" + moe; // Now OK with non-member function 26 | stooges.display(); // LarryMoe 27 | 28 | Mystring two_stooges = moe + " " + "Larry"; 29 | two_stooges.display(); // Moe Larry 30 | Mystring three_stooges = moe + " " + larry + " " + "Curly"; 31 | three_stooges.display(); // Moe larry Curly 32 | 33 | return 0; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/Mystring-operators/Mystring-operator-methods.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o ./Debug/Mystring.cpp.o 2 | -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/Mystring-operators/Mystring-operators.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o ./Debug/Mystring.cpp.o 2 | -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/Mystring-operators/Mystring.h: -------------------------------------------------------------------------------- 1 | #ifndef _MYSTRING_H_ 2 | #define _MYSTRING_H_ 3 | 4 | class Mystring 5 | { 6 | private: 7 | char *str; // pointer to a char[] that hold a C-style string 8 | public: 9 | Mystring(); // No-args constructor 10 | Mystring(const char *s); // Overloaded constructor 11 | Mystring(const Mystring &source); // Copy constructor 12 | Mystring( Mystring &&source); // Move constructiror 13 | ~Mystring(); // Destructor 14 | 15 | Mystring &operator=(const Mystring &rhs); // Copy assignment 16 | Mystring &operator=(Mystring &&rhs); // Move assignment 17 | 18 | Mystring operator-() const; // make lowercase 19 | Mystring operator+(const Mystring &rhs) const; // concatenate 20 | bool operator==(const Mystring &rhs) const; 21 | 22 | void display() const; 23 | 24 | int get_length() const; // getters 25 | const char *get_str() const; 26 | }; 27 | 28 | #endif // _MYSTRING_H_ 29 | -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/Mystring-start/Mystring-start.txt: -------------------------------------------------------------------------------- 1 | ./Debug/main.cpp.o ./Debug/Mystring.cpp.o 2 | -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/Mystring-start/Mystring.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "Mystring.h" 4 | 5 | // No-args constructor 6 | Mystring::Mystring() 7 | : str{nullptr} { 8 | str = new char[1]; 9 | *str = '\0'; 10 | } 11 | 12 | // Overloaded constructor 13 | Mystring::Mystring(const char *s) 14 | : str {nullptr} { 15 | if (s==nullptr) { 16 | str = new char[1]; 17 | *str = '\0'; 18 | } else { 19 | str = new char[std::strlen(s)+1]; 20 | std::strcpy(str, s); 21 | } 22 | } 23 | 24 | // Copy constructor 25 | Mystring::Mystring(const Mystring &source) 26 | : str{nullptr} { 27 | str = new char[std::strlen(source.str )+ 1]; 28 | std::strcpy(str, source.str); 29 | } 30 | 31 | // Destructor 32 | Mystring::~Mystring() { 33 | delete [] str; 34 | } 35 | 36 | // Display method 37 | void Mystring::display() const { 38 | std::cout << str << " : " << get_length() << std::endl; 39 | } 40 | 41 | // length getter 42 | int Mystring::get_length() const { return std::strlen(str); } 43 | 44 | // string getter 45 | const char *Mystring::get_str() const { return str; } 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/Mystring-start/Mystring.h: -------------------------------------------------------------------------------- 1 | #ifndef _MYSTRING_H_ 2 | #define _MYSTRING_H_ 3 | 4 | class Mystring 5 | { 6 | private: 7 | char *str; // pointer to a char[] that holds a C-style string 8 | public: 9 | Mystring(); // No-args contstructor 10 | Mystring(const char *s); // Overloaded contstructor 11 | Mystring(const Mystring &source); // Copy constructor 12 | ~Mystring(); // Destructor 13 | void display() const; 14 | int get_length() const; // getters 15 | const char *get_str() const; 16 | 17 | }; 18 | 19 | #endif // _MYSTRING_H_ 20 | -------------------------------------------------------------------------------- /Section14-OperatorOverloading/section14_source_code/Mystring-start/main.cpp: -------------------------------------------------------------------------------- 1 | // Section 14 2 | // Mystring - starting point 3 | #include 4 | #include "Mystring.h" 5 | 6 | using namespace std; 7 | 8 | int main() { 9 | Mystring empty; // no-args constructor 10 | Mystring larry("Larry"); // overloaded constructor 11 | Mystring stooge {larry}; // copy constructor 12 | 13 | empty.display(); 14 | larry.display(); 15 | stooge.display(); 16 | 17 | return 0; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /Section22-Bonus_Section-Using_Visual_Studio_Code/test1/test1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section22-Bonus_Section-Using_Visual_Studio_Code/test1/test1 -------------------------------------------------------------------------------- /Section22-Bonus_Section-Using_Visual_Studio_Code/test1/test1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | cout << "Hello test1!" << endl; 6 | return 0; 7 | } -------------------------------------------------------------------------------- /Section22-Bonus_Section-Using_Visual_Studio_Code/test1/test1.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.test1 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section22-Bonus_Section-Using_Visual_Studio_Code/test1/test1.dSYM/Contents/Resources/DWARF/test1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section22-Bonus_Section-Using_Visual_Studio_Code/test1/test1.dSYM/Contents/Resources/DWARF/test1 -------------------------------------------------------------------------------- /Section22-Bonus_Section-Using_Visual_Studio_Code/test2/test2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section22-Bonus_Section-Using_Visual_Studio_Code/test2/test2 -------------------------------------------------------------------------------- /Section22-Bonus_Section-Using_Visual_Studio_Code/test2/test2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | cout << "Hello test2!" << endl; 6 | return 0; 7 | } -------------------------------------------------------------------------------- /Section22-Bonus_Section-Using_Visual_Studio_Code/test2/test2.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.test2 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /Section22-Bonus_Section-Using_Visual_Studio_Code/test2/test2.dSYM/Contents/Resources/DWARF/test2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonyclyan/Beginning_CPP_Programming/4c87526dd49ec92ad06a76f6c24d7a0ce9e38d77/Section22-Bonus_Section-Using_Visual_Studio_Code/test2/test2.dSYM/Contents/Resources/DWARF/test2 --------------------------------------------------------------------------------