Erste Schritte mit C++



  • Hallo, ich möchte nun endlich anfangen eine C Sprache zu Lernen. Ich Kann Bereits C#, Java, VB, ASP, PHP, VBA nun folgende fragen hätte ich wäre nett wenn mir diese Jemand erklären kann

    1 Welche Sprache ist Besser und Umfangreicher
    2 Welche Sprache ist einfacher zu Lernen
    3 Kann ich das Visual Studio 2012 Express Verwenden für C ?
    4 Was ist eine Header Datei ?
    5 Giebt es Irgendwo Kostenlose Bücher ?

    Grüße Andy



  • 1.- Ja

    2.- Das kommt drauf an. Da du ja schon Java und C# kannst, wirst du viele Dinge aus C++ wiedererkennen. Aber du wirst auch einige Stolpersteine finden, die du in Java und C# nicht hast (weil Garbage Collection z.B.).

    3.- Ja, jeder C++ Compiler ist abwärtskompatibel zu C. (Visual Studio ist für mich persönlich auch das NonPlusUltra der IDE's)

    4.- Das lernst du am besten in einem Buch deiner Wahl oder auch in irgendeinem Tutorial oder Forumsbeitrag.

    5.- Jain, es gibt glaube ich so Späße von Galileo Computing, aber das sind eben nur Späße und für Anfänger nicht zu empfehlen. Guck mal hier durch.



  • Ja, jeder C++ Compiler ist abwärtskompatibel zu C.

    NEIN!?

    Giebt es Irgendwo Kostenlose Bücher ?

    Ja, Thinking in C++ V. 1 & 2.



  • Sone schrieb:

    Ja, jeder C++ Compiler ist abwärtskompatibel zu C.

    NEIN!?

    Beweise?


  • Mod

    out schrieb:

    Sone schrieb:

    Ja, jeder C++ Compiler ist abwärtskompatibel zu C.

    NEIN!?

    Beweise?

    int *i = malloc(1);
    


  • SeppJ schrieb:

    out schrieb:

    Sone schrieb:

    Ja, jeder C++ Compiler ist abwärtskompatibel zu C.

    NEIN!?

    Beweise?

    int *i = malloc(1);
    

    Fehlt da echt so viel Typsicherheit? Das ist hart...




  • Mod

    cooky451 schrieb:

    C++: https://ideone.com/YeFMQF
    C: https://ideone.com/eAo8xo

    Das kann man auch noch eine Stufe weiter treiben:
    C++: https://ideone.com/oHqzmY
    C: https://ideone.com/gG3fJ0



  • SeppJ schrieb:

    cooky451 schrieb:

    C++: https://ideone.com/YeFMQF
    C: https://ideone.com/eAo8xo

    Das kann man auch noch eine Stufe weiter treiben:
    C++: https://ideone.com/oHqzmY
    C: https://ideone.com/gG3fJ0

    Also da steige ich aus. Das eine Entität Deklariert sein muss, bevor man sie benutzen kann, ist für mich selbstverständlich.

    Es gibt übrigens ein riesiges Kapitel über Kompabilität im C++-Standard: §C.1.

    Ein paar Auszüge:

    Change: Type of character literal is changed from int to char
    Rationale: This is needed for improved overloaded function argument type matching. For example:

    int function( int i );
    int function( char c );
    function( ’x’ );
    

    It is preferable that this call match the second version of function rather than the first.
    Effect on original feature: Change to semantics of well-defined feature. ISO C programs which depend on

    sizeof(’x’) == sizeof(int)
    

    will not work the same as C++ programs.
    Difficulty of converting: Simple.
    How widely used: Programs which depend upon sizeof(’x’) are probably rare.
    Subclause 2.14.5:



  • Sone schrieb:

    Also da steige ich aus. Das eine Entität Deklariert sein muss, bevor man sie benutzen kann, ist für mich selbstverständlich.

    Ist es ja auch, nur deklariert die Verwendung das Symbol implizit. 🤡



  • Change: String literals made const
    The type of a string literal is changed from “array of char” to “array of const char.”
    The type of a char16_t string literal is changed from “array of some-integer-type” to “array of const char16_t.”
    The type of a char32_t string literal is changed from “array of some-integer-type” to “array of const char32_t.”
    The type of a wide string literal is changed from “array of wchar_t” to “array of const wchar_t.”
    Rationale: This avoids calling an inappropriate overloaded function, which might expect to be able to
    modify its argument.
    Effect on original feature: Change to semantics of well-defined feature.
    Difficulty of converting: Syntactic transformation. The fix is to add a cast:

    char* p = "abc"; // valid in C, invalid in C++
    void f(char*) 
    {
        char* p = (char*)"abc"; // OK: cast added
        f(p);
        f((char*)"def"); // OK: cast added
    }
    

    How widely used: Programs that have a legitimate reason to treat string literals as pointers to potentially modifiable memory are probably rare.

    Dazu noch ganz geile Sachen wie

    Change: C++ does not have “tentative definitions” as in C E.g., at file scope,

    int i;
    int i;
    

    is valid in C, invalid in C++. This makes it impossible to define mutually referential file-local static objects, if initializers are restricted to the syntactic forms of C.
    For example,

    struct X { int i; struct X *next; };
    static struct X a;
    static struct X b = { 0, &a };
    static struct X a = { 1, &b };
    

    Rationale: This avoids having different initialization rules for fundamental types and user-defined types.
    Effect on original feature: Deletion of semantically well-defined feature.
    Difficulty of converting: Semantic transformation.
    Rationale: In C++, the initializer for one of a set of mutually-referential file-local static objects must invoke
    a function call to achieve the initialization.
    How widely used: Seldom.

    Change: Main cannot be called recursively and cannot have its address taken
    Rationale: The main function may require special actions.
    Effect on original feature: Deletion of semantically well-defined feature
    Difficulty of converting: Trivial: create an intermediary function such as mymain(argc, argv).
    How widely used: Seldom

    Edit: Mir fällt gerade auf, ich könnte so C lernen... einfach dieses Kompabilitätskapitel durchackern...


Anmelden zum Antworten