SlideServe
Menu
Préférences
© SlideServe · v2026

Quick Summary C++/CLI Basics

xavier-dunn avatar
15 diapositives · 304 Views · Nov 29, 2014

This overview introduces the fundamental aspects of C++/CLI, covering key concepts like data types, control structures, and arrays. Explore primitive data types including integers, floating-point numbers, booleans, and characters. Understand control flow with structures like if-else statements and loops (for, while). Learn about single and multi-dimensional arrays, their creation, and manipulation. The guide will also touch on memory management, handles, and pointers in the context of C++/CLI. Perfect for beginners looking to grasp the essentials of C++/CLI programming.

Quick Summary C++/CLI Basics - slide 1
01 / 15Quick Summary C++/CLI Basics
1 / 17

Télécharger la présentation

Quick Summary C++/CLI Basics
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Quick Summary C++/CLI Basics • Data Types • Controls • Arrays • In-class assignments

  2. Namespaces namespaceMyNamespace { // …. } MyNamespace::func1() using namespace OtherNamespace; Comments: // /* xxxx */

  3. Basic Data Types • Type • Range • Literals/constants and variables • Operators and expressions • Assignment • Input and output

  4. Primitive Data Types in C++/CLI • Integer: • Int16 (short); UInt16 (unsinged short) • Int32 (int or long); UInt32(unsigned int or long) • Int64 (long long); UInt64(unsigned long long, _int64) int x, y(1), z = 123; (signed, 32 bits) int x = y = z = 200; Console::WriteLine(0x10); Console::WriteLine(-0x10); // negative hex 10 is base-10 -16 • Floating: • Single (float, 32bits) • Double (double, 64bits)

  5. Primitive Data Types in C++/CLI • Boolean (bool, true or false) • Character (Char, 16bits, unsigned unicode) • Character and escape sequence chara = ‘A’; // character ‘A’ Charb = L‘A’; // unicode ‘A’ Char c = L‘\x0041’; // hex 41 is ASCII ‘A’ chard = ‘\t’; // tab escape Char e = L‘\\’; // unicode backslash escape

  6. Handles vs Pointers Handle: safe code Pointer: unsafe code Pointer: * Reference data in C Run-Time heap, need to handle memory management yourself pointer’s address can be manipulated Return from new after creating an instance of a reference type object in CRT heap • Handle: ^ • Reference data in managed heap (CLR offers memory management) • Handle’s address can not be manipulated (no add or subtract offsets to it • Return from gcnew after creating an instance of a reference type object in managed heap

  7. Operators, Expressions and Assignments, Precedence and Associativity • Arithmetic Operators • Unary Operators • Bitwise and Shift Operators • Relational Operators • Logical Operators • Ternary Operator

  8. Quick Summary C++/CLI Basics • Data Types • Controls • Arrays • In-class assignments

  9. Control Structures • Structured Programming • Selection • if • if else • switch(break) • Repetition (break, continue) • while • do … while • for

  10. break & continue int sum=0; for (int i=1; i<=10; i++) { if (i%5==0) continue; sum += i; // sum = sum+i; } int sum=0; for (int i=1; i<=10; i++) { if (i%5==0) break; sum += i; // sum = sum+i; }

  11. Quick Summary C++/CLI Basics • Data Types • Controls • Arrays • In-class assignments

  12. Arrays • Arrays • One dimensional array • Two or multiple dimensional array

  13. Array in C++/CLI • Array, element, index(or subscript) • array<int> ^ a = gcnew array<int>(12); • array<int> ^ a = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; • a[0], a[1],…, and a[11] • a->Length • array<String ^> ^d = {“Sun”, “Mon”, “Tue”, “Wed”, “Thu”, “Fri”, “Sat”}; • int main(array<System::String ^> ^args) {}

  14. Array in C++/CLI • Multi-dimensional Array • array<int, 2> ^ b = gcnew array<int, 2>(4,3); • array<int, 2> ^ b = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {0, 1, 2}}; • b[0,0], b[0,1],…, b[3,2]; • b->Rank, b->GetLength(0), b->GetLength(1)

  15. Quick Summary C++ for .NET • Data Types • Controls • Arrays • In-class assignments • Control • Array