Debugging
1. Debugging
Hey i am giving you a very cool piece of code which will be very much helpful in debugging.
Let me give you an example:
The output of the function
So what this following piece of code does is that it takes your variable and then by writing (#x)
it converts the name of the variable into a string and then obviously the variable x holds the value of x so the second half of the code <<x<<
will print the value of x;
I think you should try to run the code once and then you will understand the working of the code.
The line you just use implements the use of preprocessor directives commonly referred to with the name macro. For more, you must visit this link.
2. Commenting
There is a nice article on the pros and cons of commenting, click here Efficiency comes with practice (writing more and more programs). There is a whole chapter on comments in Book Clean Code by Robert C. Martin. Click here for the book. Summary of the chapter:
In his book Clean Code, advocates using comments for the following purposes: 1.Explanation of Intent 2.Clarification 3.Warnings 4.Amplification 5.ToDo At a minimum, comments should describe what each public member does and how to use it, and explain all parameters and return values with acceptable ranges (e.g. between 1 and 1000) for each.
3. References to a Live Project
Once you are done with this project then you should have a look at the htop package. I have looked at all the files and found very great details, very minute details. I was so impressed that I even made changes to my code according to those minute details. It is good if you want to explore that too but i would recommend if you get stuck with any terms then google it and even after that you do not get it then you should just leave it like that because some of the terms might come up from Operating Systems and knowing just a a little bit (You might understand it the wrong way) about a very important and heavy concept is not recommended from my side.
4. Awesome Resources on Web
Here are some awesome resources I like to go through as additional material for C++ OOP:
You can check out from chapter 8-12 and even later chapters to do some more practice in OOP -- learncpp
A short and quick but wonderful tutorial on OOP -- Object Oriented Programming
Great series on basic C++ with some important OOP concepts throughout the series -- C++ Beginner Game Programming
A good overview of OOP though it's covered in Python you will find a lot of concepts well explained -- Object Oriented Programming
A good amount of OOP concepts are used while making this role-playing game. I am posting only the first part of the series but there are 4 parts for this series so do complete them. You will have a fun time doing it -- Code-It-Yourself! Role Playing Game
Another good resource on Polymorphism -- Polymorphism
A great video on Pointers -- What Are Pointers? C++
Here are a few additional resources you can look at it for more information on Object Oriented Programming:
CppCon 2019 – Back to Basics Object Oriented Programming - This back to basics series is so much awesome. I would recommend you to go through all of the back to basics CppCon
You may also find the following reading material helpful:
5. Some Linux Exclusive Resources
How to View Running processes on Linux! Please find the link
Go Further
These resources can help you step up your game:
Tools for C++:
Go deeper into the Project:
CMake and Make
In the beginning, it is usually not very clear what those build systems or build system generators are and how they can be beneficial to us. I would like to share with you some resources to help with this.
Overview of CMake and how it manages cross-platform build processes.
Introduction to CMake by examples that apply single file project, and multiple directory projects.
Please note that CMake isn't a build system, it's a build system generator. This is why we need to invoke make after running cmake. Running cmake generates Makefiles with the appropriate platform dependencies, and running make actually uses them.
However we don't need to write Make files, as CMake does this for us, it is good to understand about build systems.
Introduction to Make and how it uses the Makefile generated by CMake to build the system.
How to write Makefiles. This is just for your information. It is already automated through CMake.
When you write a program, the compiler will check to ensure that you have followed the rules of the language in which you have written code. If you have done something that definitively violates the rules of the language, during compilation the compiler will emit an error, providing both line number containing the error, and some text about what was expected vs what was found. The actual error may be on that line, or on a preceding line. Once you’ve identified and fixed the erroneous line(s) of code, you can try compiling again.
In other cases, the compiler may find code that seems like it might be in error, but the compiler can’t be sure (remember the motto: “trust the programmer”). In such cases, the compiler may opt to issue a warning. Warnings do not halt compilation but are notices to the programmer that something seems amiss.
In most cases, warnings can be resolved either by fixing the error the warning is pointing out or by rewriting the line of code generating the warning in such a way that the warning is no longer generated.
In rare cases, it may be necessary to explicitly tell the compiler to not generate a particular warning for the line of code in question. C++ does not support an official way to do this, but many individual compilers (including Visual Studio and GCC) offer solutions (via non-portable #pragma directives) to temporarily disable warnings.
Some of the best practices about compiler warnings :
Don’t let warnings pile up. Resolve them as you encounter them (as if they were errors).
Turn your warning levels up to the maximum, especially while you are learning. It will help you identify possible issues.
It is also possible to tell your compiler to treat all warnings as if they were errors (in which case, the compiler will halt compilation if it finds any warnings). This is a good way to enforce the recommendation that you should fix all warnings (if you lack self-discipline, which most of us do).
For More Visit these links
Relationships among classes in object-oriented programming
Object-oriented programming generally supports 4 types of relationships that are: inheritance, association, composition, and aggregation. All these relationships is based on "is a" relationship, "has-a" relationship, and "part-of" relationship. This is a very important topic to get a good grip on. Please refer to this page for more details on it.
GDB
Last updated