Menu
CoddyTech
Course

C++ for Dart Developers

Transfer Dart experience to C++17: values, flow, functions, containers, headers, classes, virtual dispatch, RAII, and move ownership. Build a connected library desk.

Dart and C++ side by side

The same program in Dart and in C++, from the lessons of this course.

  1. Strings and Output

    A Dart String is an immutable sequence of UTF-16 code units, and length counts those code units. C++ std::string owns a mutable byte sequence; stream insertion formats values. Length counts bytes, not Unicode characters, so a UTF-8 accented letter counts…

    Dart
    1void main() {2  var name = 'café';3  print(name.length);4}
    C++
    1#include <iostream>2#include <string>3#include <vector>4#include <array>5#include <map>6#include <set>7#include <algorithm>8#include <memory>9#include <sstream>10#include <stdexcept>11#include <utility>12
    13int main(){14std::string name="café";std::cout<<name.size()<<"\n";15}
  2. Text Equality

    Dart == on strings already compares contents, and identical() asks whether two references are the same object. A Dart class that does not override operator == falls back to identity, while a C++ class without operator== cannot be compared with == at all. C++…

    Dart
    1class Tag {2  final String name;3  Tag(this.name);4}5
    6void main() {7  var a = 'red';8  var b = 'RED'.toLowerCase();9  print('${a == b} ${Tag(a) == Tag(b)}');10}
    C++
    1#include <iostream>2#include <string>3#include <vector>4#include <array>5#include <map>6#include <set>7#include <algorithm>8#include <memory>9#include <sstream>10#include <stdexcept>11#include <utility>12
    13int main(){14std::string a="red",b="red";std::cout<<std::boolalpha<<(a==b)<<"\n";15}
  3. Fixed-size Arrays

    Dart has no fixed-size array type: List.filled(3, 0) makes a fixed-length list whose length is checked at run time, and assigning it to another variable shares the same list. C++ std::array<T,N> is a fixed-size value type. Its size is part of its type, and…

    Dart
    1void main() {2  var a = List<int>.filled(3, 0);3  a[1] = 5;4  var b = a;5  b[0] = 4;6  print('${a.length} ${a[0]} ${a[1]}');7}
    C++
    1#include <iostream>2#include <string>3#include <vector>4#include <array>5#include <map>6#include <set>7#include <algorithm>8#include <memory>9#include <sstream>10#include <stdexcept>11#include <utility>12
    13int main(){14std::array<int,3> a{4,5,6};auto b=a;b[0]=9;std::cout<<a.size()<<" "<<a.at(0)<<" "<<b.at(0)<<"\n";15}
  4. Value Copies

    Every Dart variable holds a reference to an object, so final b = a; makes b another name for the same List; you copy with List.of(a) or [...a]. C++ container assignment copies values. C++ vector and string copies own independent storage. Copying a raw pointer…

    Dart
    1void main() {2  final a = [4];3  final b = a;4  b.add(9);5  print('${a.length} ${b.length}');6}
    C++
    1#include <iostream>2#include <string>3#include <vector>4#include <array>5#include <map>6#include <set>7#include <algorithm>8#include <memory>9#include <sstream>10#include <stdexcept>11#include <utility>12
    13int main(){14std::vector<int> a{4};auto b=a;b.push_back(9);std::cout<<a.size()<<" "<<b.size()<<"\n";15}
  5. Functions and Returns

    Dart and C++ both allow top-level functions outside any class. Dart can call a top-level function defined further down the file; C++ needs a declaration before the call. C++ function declarations establish parameter and return types. A return value is not…

    Dart
    1void main() {2  print(twice(4));3}4
    5int twice(int n) => n * 2;
    C++
    1#include <iostream>2#include <string>3#include <vector>4#include <array>5#include <map>6#include <set>7#include <algorithm>8#include <memory>9#include <sstream>10#include <stdexcept>11#include <utility>12
    13int triple(int n){return 3*n;}14int main(){15std::cout<<triple(4)<<"\n";16}
  6. Streams and Exact Parsing

    Dart's int.parse throws a FormatException on text that is not a whole number, and int.tryParse returns null. C++ stream extraction reads as much as fits and reports success through stream state, so 7x yields 7 and leaves x unread. Validate conversion and…

    Dart
    1void main() {2  final parts = 'oak 7x'.split(' ');3  final n = int.tryParse(parts[1]);4  print(n == null ? 'rejected ${parts[1]}' : '${parts[0]}/$n');5}
    C++
    1#include <iostream>2#include <string>3#include <vector>4#include <array>5#include <map>6#include <set>7#include <algorithm>8#include <memory>9#include <sstream>10#include <stdexcept>11#include <utility>12
    13int main(){14std::istringstream in("oak 7x");std::string word;int n;if(in>>word>>n)std::cout<<word<<"/"<<n<<"\n";15std::string rest;if(in>>rest)std::cout<<"left: "<<rest<<"\n";16}

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

More courses for Dart developers

Learn C++ from another language

Frequently asked questions

Who is C++ for Dart Developers for?

For people who already write Dart and want to learn C++. Each lesson starts from Dart you know and shows how C++ does the same thing, so you skip the beginner basics.

Do I need to know C++ already?

No. The course starts with your first C++ program. You need Dart basics: variables, conditions, loops, functions and collections.

How many lessons does C++ for Dart Developers have?

C++ for Dart Developers contains 48 interactive lessons you can complete at your own pace.

What does C++ for Dart Developers cover?

The course is organized into chapters covering: C++ Files and Values, Conditions and Iteration, Standard Containers, Copies and Algorithms, and more.

Is C++ for Dart Developers free?

Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.

Coddy programming languages illustration

Start C++ for Dart Developers for free

Get started