I'd move the logically related chunks of code ("chapters") to separate functions. For example, you can introduce new class 'Utils', and put there all these chapters as static functions: class Utils { public: static void createStrings(); static void playWithCtorsAndArgs(); static void reachEachCharOneByOne(); static void compareAndSearch(); static void modifyAndParse(); }; In this case your main function will be clean and short as follows: int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); // Utils::createStrings(); // Utils::playWithCtorsAndArgs(); // Utils::reachEachCharOneByOne(); // Utils::compareAndSearch(); Utils::modifyAndParse(); return a.exec(); } Another one benefit of such approach is that you don't need comments (as names of chapters) anymore, because your functions substitute this functionality by function names. Now the names of the chapters are part of your code, which is considered as 'best practice' - your code is self-explanatory (self-documented) now.
28:05 no it does not in your case, due to implicit sharing! It does not copy the data as long as you not write to the passed string!
I'd move the logically related chunks of code ("chapters") to separate functions.
For example, you can introduce new class 'Utils', and put there all these chapters as static functions:
class Utils
{
public:
static void createStrings();
static void playWithCtorsAndArgs();
static void reachEachCharOneByOne();
static void compareAndSearch();
static void modifyAndParse();
};
In this case your main function will be clean and short as follows:
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
// Utils::createStrings();
// Utils::playWithCtorsAndArgs();
// Utils::reachEachCharOneByOne();
// Utils::compareAndSearch();
Utils::modifyAndParse();
return a.exec();
}
Another one benefit of such approach is that you don't need comments (as names of chapters) anymore, because your functions substitute this functionality by function names. Now the names of the chapters are part of your code, which is considered as 'best practice' - your code is self-explanatory (self-documented) now.
There is range-based for loop since C++11, so, I think, it way much better to use it instead of foreach:
for (auto const &item : list) { qInfo()
The increased quality is superb!
great video, This covers the basics of everything I need to know about QString without having to read the documents.
I love your work.
Great!
I wonder how you can convert a QByteArray to a Windows-compatible wchar_t string.
Thank you brother, it's really helpful lesson
Great video! Thank for making this!
Excelente resumen
Awesome e
very good
Can i also do that arg() thing with std::string?
no
Give a look at std::format.
Nice 💖