80 likes | 198 Vues
Explore the critical differences between C++ and Java, focusing on why C++ remains prevalent in the industry. Java is user-friendly with built-in GUIs and cross-platform capabilities, while C++ offers enhanced performance and QT for GUI development. Understand the nuances of coding in C++, including variable declarations, namespaces, and input/output streams. Learn about the compilation process using g++ and the advantage of using Makefiles for larger projects. This guide is perfect for developers looking to deepen their understanding of C++ and its applications.
E N D
Why QT/C++ Over Java? • Java is easier than C++ • Java has built in GUIs • Java is multi-platform • C/C++ is more used in industry • QT adds GUIs to C++ • QT adds multi-platform IO to C++
C++ is like C • Comments are the same • // or /* */ • Still need to include header files • #include
C++ is a little different • Declaring variables have 3 flavors • type-expr variableName; • type-expr variableName = value; • type-expr variableName (value); • Namespaces • Like a group of header files. By listing the namespace, you include all of the files.
Inputs and Outputs • cin -Standard Input (Keyboard) • cout -Standard Output (Text) • cerr -Standard Error Output (Text) • These are all examples of 'streams' Streams are a key way that C++ thinks of inputs and outputs. They are also Objects!
What is an Object? • An object is like a structure • An object has things that can be done only to that object • An object has attributes that apply only to it • Example: A car is an object
Compiling C++ • g++ file.cpp • produces 'a.out' or 'a.exe' • Makefiles can also be used (common)