ccpp concepts - cbranton/computer-system-concepts GitHub Wiki
C++ was designed to be efficient like C, but more conducive to developing large systems. Primary among the features added to this end was support for object-oriented features. C++ is not strictly object-oriented. It has often been described as "object-friendly".
Adoption is an important consideration when designing any langauge. Since C++ was hoping to expand an existing codebase, it was designed to run C unaltered. In other words, a legal C program is a legal C++ program. There are some minor exceptions to this rule[^1], but you can rely on it for the most part.
[^1]: One often cited exception is the use of C++ keywords in C programs. For example int new = 1
is legal C but not legal C++.
To compile C++ using the GNU compiler, replace gcc
with g++
. (See the Hello World example below.)
Let's start by adapting our first C program to C++.
// A first program in C++
#include <iostream>
int main ()
{
// The std:: may be omitted by including "using namespace std" above
std::cout << "Hello World!" << std::endl;
return 0;
}
We have already discovered one of the differences with C++, namely stream input and output. std::cout
is the C++ designation of the standard output stream. (Somewhat confusingly here, the std
in std::out
denotes the C++ standard library, not the standard output.) The <<
operator places the string on the output stream. The std::endl
is a platform-independent newline marker. In most cases it will be equivalent to '\n'
)
Compiling and executing a C++ program is generally the same as with C. For example:
g++ -o hello hello.cpp
g++ -S -masm=intel hello.cpp
The first form above compiles hello.cpp
into a file called hello
. The second creates assembly langauge output in hello.s
.
Which means memory should probably move up here.
File pointers and file descriptors
FILE object. <cstdio>
File pointer -- example file struct
typedef struct _iobuf
{
char* _ptr;
int _cnt;
char* _base;
int _flag;
int _file;
int _charbuf;
int _bufsiz;
char* _tmpfname;
} FILE;
Requests the command processor to execute a command
Configure SSH if you wish to use CLion
https://www.jetbrains.com/help/clion/quick-tutorial-on-configuring-clion-on-windows.html