Bureaucrats, Check users, Interface administrators, Push subscription managers, Suppressors, Administrators, userexport
1,015
edits
Undefishin (talk | contribs) No edit summary |
Undefishin (talk | contribs) (fix inconsistent spacing) |
||
The current standardized C++ version is C++20, which added the "consteval" keyword and the Concepts TS, among lots of other improvements.
The C++ language has played a big role in CollabVM's history, most notably in CollabVM version 1.1 and onward, which is the rewrite of the CollabVM server by Cosmic Sans, along with CollabVM 2.0 also by Cosmic. It is also used in CollabVM 3.0 by modeco80, which is similarly known as a prolific and incredibly talented C++ programmer.
== Examples ==
=== Hello World ===
This program prints out "Hello, world!" to the console.
int main() { // Main function: must return a variable of int type. This is the program's exit code.
}
</syntaxhighlight>
=== Fizz Buzz ===
This is a more complex example: this program prints out "Fizz" for each multiple of 3, "Buzz" for each multiple of 5, and "Fizz Buzz" for each multiple of both. This program demonstrates functions besides <code>main()</code>, the <code>if</code> statement, the ternary operator (<code>condition ? ifTrue : ifFalse</code>), and loops.
enum class FizzBuzzType {
None,
FizzBuzz,
Fizz,
Buzz
};
FizzBuzzType GetFizzBuzzType(int number) {
}
int main() {
}
return 0;
}
</syntaxhighlight>
== Virtual Functions ==
Virtual functions are functions part of a class which can be implemented in another inheriting class, allowing the actual implementation to be located somewhere else or even hidden from code.
The example code here shows how a completely abstract class can be implemented inside of a different translation unit (source file), so that the main program only needs the interface to work.
Interface.h:
// and also sets this class up for proper RTTI data generation.
virtual ~MyInterface() = default;
// Do something.
virtual void Run() = 0;
namespace {
class MyInterfaceImpl : public MyInterface {
public:
== Generic code ==
C++ supports "templates" which are the front and center way of writing generic code. Alongside this, is now the Concepts TS, allowing us to
with ease constrain what types a template can operate on.
}
</syntaxhighlight>
[[Category:Programming Languages]]
|
edits