Zum Hauptinhalt springen
ProdukteDesktop-WerkzeugeTASTECADZeichnungsprüfungTASTEFILESDateiverwaltungTASTEFTPDateiübertragungTASTESSHRemote-ArbeitsbereichTASTEZIPKomprimieren und EntpackenTASTEWINMDateiverwaltungEntwicklerwerkzeugeTASTECODEIntegrierte Entwicklungsumgebung für RustTASTESTUDIOIntegrierte Entwicklungs- und TestumgebungTASTEETLDatenintegration (ETL)ServerTASTEREMOTERemote-Desktop-ServerTASTEGEOGeodatenserverTASTEMAILE-Mail-ArbeitsbereichInvestierenTASTESTOCKDesktop-App für automatischen AktienhandelErste SchritteDownloadsDokumentationKaufenAlle Produkte
Marktplatz
Neuigkeiten
TechnikNeuigkeitenEntwickler-News von heuteEntwicklerdokuProgrammiersprachenRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWeb-Frontend-FrameworksNext.jsReactVue.js · NuxtSvelteKitAngularServer-FrameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressApp- & Desktop-FrameworksTauriFlutterReact NativeElectronAlgorithmenAlgorithmus-GrundlagenKernalgorithmenFortgeschrittene AlgorithmenAlgorithmen für die Praxis
CommunityProjekteEntwicklungslogsPromptsProbleme mit KI-ToolsShowcaseCommunity-Leitfaden
ZusammenarbeitWissenstransferWebsite-AufbauDesktop-App-AufbauRelease- und ZahlungspipelineVertriebspartnerKontakt
DiensteRemote-DesktopIndividuelle Installationspakete
TASTEDEV
Produkte

Desktop-Werkzeuge

TASTECADKomplexe Zeichnungen, mühelos geöffnetTASTEFILESNur die Dateien, die zählen – in BestzeitTASTEFTPDer aufgeräumteste Weg für Ihre DateienTASTESSHDie stärkere Verbindung zu Ihren ServernTASTEZIPSchneller packen, sicherer entpackenTASTEWINMEin tastaturorientierter Dateimanager mit zwei Fenstern

Entwicklerwerkzeuge

TASTECODERust-Apps bearbeiten, bauen, debuggen und testen – alles in einem FensterTASTESTUDIOVom Bearbeiten bis zu Remote-Tests und freigegebenen KI-KorrekturenTASTEETLDaten bewegen, die Werte im Blick

Server

TASTEREMOTEEin Remote-Desktop auf Ihrem eigenen ServerTASTEGEOEin GeoServer-kompatibler Geodatenserver, neu aufgebaut in RustTASTEMAILIhre E-Mail wieder in Ihrer Hand

Investieren

TASTESTOCKAutomatischer Aktienhandel nach Ihren Regeln: wann und was

Erste Schritte

DownloadsNeueste Versionen aller ProdukteDokuSo nutzen Sie jedes ProduktKaufenAbos und DauerlizenzenAlle ProdukteAlle Produkte im Überblick
Alle Produkte
MarktplatzNeuigkeiten
Technik

Neuigkeiten

Entwickler-News von heuteOffizielle Meldungen zu Sprachen, Frameworks, GitHub und KIEntwicklerdokuAnleitungen zu Sprachen, Frameworks und Algorithmen

Programmiersprachen

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Web-Frontend-FrameworksNext.jsReactVue.js · NuxtSvelteKitAngular
Server-FrameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
App- & Desktop-FrameworksTauriFlutterReact NativeElectron

Algorithmen

Algorithmus-GrundlagenKomplexitätsanalyse · Sortieren · Suchen · Grundlegende Datenstrukturen · Bäume und HeapsKernalgorithmenGraphtraversierung · Kürzeste Wege und minimale Spannbäume · Dynamische Programmierung · Greedy-Algorithmen · Teile und herrsche · BacktrackingFortgeschrittene AlgorithmenZeichenkettenalgorithmen · Mathematik und Zahlentheorie · Bitmanipulation · Segmentbäume · Union-FindAlgorithmen für die PraxisStrategie für Coding-Interviews · LRU-Cache · Rate Limiting · Konsistentes Hashing
Alle Entwicklungsdokumente
Community
ProjekteEntwickler und Projekte entdeckenEntwicklungslogsEntscheidungen und ErkenntnissePromptsWiederverwendbare AnweisungenProbleme mit KI-ToolsProbleme und Workarounds für Claude, Codex, GeminiShowcaseFertige ErgebnisseCommunity-LeitfadenWie wir offen entwickeln
Zusammenarbeit
WissenstransferNative Apps mit Rust und eguiWebsite-Aufbau10 Sprachen, Konten, Dokumentation und DownloadsDesktop-App-AufbauRust und egui, ohne WebViewRelease- und ZahlungspipelineSignatur, MSI, deb, rpm, AppImage, PrüfsummenVertriebspartnerEmpfehlen und 30 % erhaltenKontaktEntwicklung, Partnerschaft, Investition
Dienste
Remote-DesktopIhren Computer im Browser erreichenIndividuelle InstallationspaketeNur nötige Funktionen, Einstellungen vorab
Kaufen
DE
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Anmelden
Anmelden
TASTEDEV

Von kleinen Werkzeugen zu besserer Entwicklung.

support@tastedev.netTASTEDEV unterstützen
ProdukteProduktübersichtKaufenDokuDownloadsMarktplatzSupport
CommunityProjekteEntwicklungslogsPromptsProbleme mit KI-ToolsShowcase
RichtlinienÜber unsDatenschutzerklärungNutzungsbedingungenAbo-BedingungenRückerstattungCommunity-Richtlinien
KontoAnmeldenRegistrieren
Besucher
Heute
Gestern
Aufrufe gesamt
Firma
GXSOFT
Vertretungsberechtigt
CHOI YOUNG GU
Handelsregisternummer
853-44-00368
Anschrift
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Telefon
+82-10-4404-1523
E-Mail
whitecalvin@tastedev.net
Datenschutzbeauftragter
CHOI YOUNG GU

© 2026 TASTEDEVProduktinformationen basieren auf verifizierten Entwicklungsquellen.Veröffentlicht · wird verbessert

C++-Dokumentation
C++
Getting StartedSyntax BasicsTypes and DataModules and PackagesErrors and TestingKey Concepts
Diskussionen

C++-Anleitung · 2/6

Syntax Basics

Dieses Kapitel ist vorerst nur auf Englisch verfügbar.

This chapter covers the building blocks you will use in every C++ program: the main function, variables and auto, references, functions and overloading, control flow, and printing output.

main and statements

Every C++ program starts in main. Statements end with a semicolon, blocks are wrapped in braces, and comments come in two flavors: // for a single line and /* ... */ for a span.

#include <iostream>

int main(int argc, char* argv[]) {
    // argc: number of arguments, argv: the arguments as C strings
    std::cout << argc << " argument(s), program: " << argv[0] << '\n';
    return 0; // optional in main: falling off the end returns 0
}

Variables and auto

A variable is declared with a type and a name. Brace initialization ({}) is worth making a habit, because the compiler rejects narrowing conversions that would silently lose data. auto deduces the type from the initializer, and const makes a value read-only.

#include <string>

int count{10};
double ratio = 0.75;
const int max_users{100};   // cannot be modified
constexpr int buffer = 256; // value known at compile time

auto name = std::string{"Kim"}; // std::string
auto total = count * 2;         // int

// int bad{3.14};  // error: narrowing from double to int

An uninitialized local variable holds an indeterminate value, and reading it is a bug. Give every variable an initial value when you declare it.

References

A reference (&) is an alias for an existing object. References are the usual way to pass large objects to functions without copying them. If the function only reads the argument, take it by const reference.

#include <string>

void add_suffix(std::string& text) {             // modifies the caller's string
    text += "!";
}

std::size_t length_of(const std::string& text) { // read-only, no copy
    return text.size();
}

int main() {
    std::string greeting{"hello"};
    add_suffix(greeting);          // greeting is now "hello!"
    auto n = length_of(greeting);  // 6
    int value = 1;
    int& alias = value;
    alias = 5;                     // value is 5 too
}

A reference must be bound when it is declared and can never be reseated to refer to something else. When you need something that can change targets or be empty, use a pointer.

Functions and overloading

A function has a return type, a name and a parameter list. Several functions can share a name as long as their parameter lists differ; this is called overloading. Parameters can also have default values.

#include <string>

int area(int w, int h) { return w * h; }
double area(double radius) { return 3.14159 * radius * radius; }

std::string repeat(const std::string& s, int times = 2) {
    std::string out;
    for (int i = 0; i < times; ++i) out += s;
    return out;
}

// area(3, 4)  -> 12
// area(1.5)   -> area of a circle
// repeat("ab") -> "abab", repeat("ab", 3) -> "ababab"
Fragen zu diesem Kapitel?
Vorheriges KapitelGetting StartedNächstes KapitelTypes and Data

The compiler picks an overload by matching the argument types at the call site. If two candidates are equally good, the call is ambiguous and won't compile.

Control flow

if, switch, while and the classic for loop look much like they do in C. Since C++11 there is also the range-based for, which visits every element of a container, and since C++17 if can declare a variable right in its header.

#include <iostream>
#include <vector>

int main() {
    std::vector<int> scores{90, 72, 85, 60};

    for (int s : scores) {               // each element by value
        std::cout << s << ' ';
    }
    for (auto& s : scores) {             // by reference, so we can modify
        s += 5;
    }
    for (const auto& s : scores) {       // read-only access
        if (s >= 90) std::cout << "A ";
        else if (s >= 80) std::cout << "B ";
        else std::cout << "C ";
    }

    if (auto n = scores.size(); n > 3) { // C++17 if with initializer
        std::cout << "\n" << n << " scores\n";
    }

    int i = 0;
    while (i < 3) { ++i; }
}

Output: iostream and std::format

std::cout works with every standard version. C++20 added std::format in <format>, which builds a string from a format string with {} placeholders, and C++23 added std::print in <print> to write formatted output directly. Standard library implementations shipped these at different times, so an older toolchain may not have them yet.

#include <format>
#include <iostream>
#include <string>

int main() {
    std::string name{"Lee"};
    int score = 92;
    std::cout << std::format("{} scored {} points.\n", name, score);
    std::cout << std::format("{:>8.2f}|\n", 3.14159); // width 8, 2 decimals
}

If std::format isn't available to you, keep using std::cout, or use the open-source {fmt} library, which the standard facility was based on.

Summary

  • Execution starts in main, and statements end with ;.
  • Prefer brace initialization, use auto for type deduction, and const or constexpr for values that never change.
  • Pass by reference to avoid copies, and by const reference when you only read.
  • Functions with different parameter lists can share a name.
  • Use range-based for to walk containers, and std::format for formatted text when your toolchain supports it.

0 Kommentare

Top-KommentareNeueste zuerst

Anmelden · Melde dich an, um einen Kommentar zu schreiben.