C++ for GDScript Developers
Transfer GDScript experience to C++17: values, flow, functions, containers, headers, classes, virtual dispatch, RAII, and move ownership. Build a connected library desk.
GDScript and C++ side by side
The same program in GDScript and in C++, from the lessons of this course.
Strings and Output
A GDScript String is a value type of Unicode characters: length() counts characters, and assigning a string to another variable gives an independent copy. C++ std::string owns a mutable byte sequence; stream insertion formats values. Length counts bytes, not…
GDScript1extends Node2 3func _ready():4 print("café".length())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}Text Equality
GDScript == compares String and Array contents, while is_same asks whether two Arrays are one shared instance; the is keyword is a type check, not an identity test. C++ operator behavior depends on the declared operand types. std::string equality compares…
GDScript1extends Node2 3func _ready():4 var a = ["red"]5 var b = ["red"]6 print(a == b)7 print(is_same(a, b))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",c="Red";std::cout<<std::boolalpha<<(a==b)<<" "<<(a==c)<<"\n";15}Fixed-size Arrays
A GDScript Array grows with append, accepts negative indexes, and is shared by reference: assigning it to another variable gives a second name for the same array. C++ std::array<T,N> is a fixed-size value type. Its size is part of its type, and normal copy…
GDScript1extends Node2 3func _ready():4 var items = [4, 8]5 items.append(12)6 var alias = items7 alias[0] = 998 print(items[-1])9 print(items.slice(0, 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 main(){14std::array<int,3> a{4,5,6};auto b=a;b[0]=99;std::cout<<a.size()<<" "<<a.at(0)<<"\n";15}Value Copies
In GDScript, Array and Dictionary are reference types: var alias := original gives one array two names, and duplicate() copies only the outer level, so nested arrays stay shared unless you call duplicate(true). Built-in value types such as int, String and…
GDScript1extends Node2 3func _ready():4 var original := [[1]]5 var alias := original6 var shallow := original.duplicate()7 var deep := original.duplicate(true)8 shallow[0].append(2)9 deep[0].append(3)10 alias.append([4])11 print(original)12 print(deep)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<std::vector<int>> a{{1}};auto b=a;15b[0].push_back(2);b.push_back({4});16std::cout<<a.size()<<" "<<a[0].size()<<" | "<<b.size()<<" "<<b[0].size()<<"\n";17}Functions and Returns
GDScript functions can be fully dynamic or carry type hints. With hints such as value: int and -> int, the parser checks the calls it can see; without them, a mismatch only shows up at runtime. A function with no declared return type may end without return…
GDScript1extends Node2 3func twice(value: int) -> int:4 return value * 25 6func describe(value: int):7 if value > 0:8 return "positive"9 10func _ready():11 print(twice(4))12 print(describe(-1))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;}14std::string describe(int n){if(n>0)return "positive";return "other";}15int main(){16std::cout<<triple(4)<<" "<<describe(-1)<<"\n";17}Streams and Exact Parsing
GDScript's String.to_int() never fails: it drops characters that are not part of a number and returns 0 when nothing is left, so "7x".to_int() is 7. To validate, call is_valid_int() before converting. C++ stream extraction reports success through the stream…
GDScript1extends Node2 3func _ready():4 var parts := "oak 7x".split(" ")5 var word := parts[0]6 var text := parts[1]7 print(word, "/", text.to_int(), " ", text.is_valid_int())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,rest;int n=0;15if(in>>word>>n)std::cout<<word<<"/"<<n;16if(in>>rest)std::cout<<" extra:"<<rest;17std::cout<<"\n";18}
Syllabus
10 chapters48 lessons1 project48 challenges99 quiz questionsC++ Files and Values
6 lessonsConditions and Iteration
5 lessonsStandard Containers
5 lessonsCopies and Algorithms
5 lessonsFunctions and Templates
5 lessonsParsing and Lifetime
5 lessonsObjects and Invariants
6 lessonsComposition and Ownership
5 lessonsProject: Library Desk
4 lessonsFinal Challenges
2 lessonsFrequently asked questions
Who is C++ for GDScript Developers for?
For people who already write GDScript and want to learn C++. Each lesson starts from GDScript 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 GDScript basics: variables, conditions, loops, functions and collections.
How many lessons does C++ for GDScript Developers have?
C++ for GDScript Developers contains 48 interactive lessons you can complete at your own pace.
What does C++ for GDScript 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 GDScript Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.