Menu
CoddyTech
Course

GDScript for C++ Developers

Move from C++ to Godot 4 GDScript: script typing, collection ownership, callables, objects, signals and explicit failure contracts. Build a stock depot in 48 genuine multi-file console lessons.

C++ and GDScript side by side

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

  1. Text and Comments

    C++ stream insertion writes the values and separators explicitly requested; std::cout does not append a newline automatically. GDScript print concatenates arguments and ends the line. Format spaces and numbers deliberately. GDScript uses indentation and #…

    C++
    1#include <iostream>2
    3int main() { std::cout << "tag " << 7 << "\n# data\n"; }
    GDScript
    1extends Node2
    3func _ready() -> void:4	print("tag", 7)5	print("# data")
  2. Branches and Values

    C++ uses braces for blocks and condition ? first : second to select an expression result. GDScript uses indentation and a selected-value-first conditional expression. In an if/else-if or if/elif chain, the first matching branch runs, so a broad early…

    C++
    1#include <iostream>2
    3int main() { int n=-2; std::cout << (n<0?"west":"east") << '\n'; }
    GDScript
    1extends Node2
    3func _ready() -> void:4	var n: int = -25	print("west" if n < 0 else "east")
  3. Array Operations

    GDScript Array is growable like std::vector, rather than fixed in extent like a built-in C++ array or std::array. append resembles push_back, but GDScript pop_back returns the removed value while vector.pop_back returns void. Read back before removal when…

    C++
    1#include <iostream>2#include <vector>3int main() { std::vector<int> items{3}; items.push_back(8); int removed=items.back(); items.pop_back(); std::cout << removed << " " << items.size() << '\n'; }
    GDScript
    1extends Node2
    3func _ready() -> void:4	var items: Array = [3]5	items.append(8)6	var removed = items.pop_back()7	print("%d %d" % [removed,items.size()])
  4. String Operations

    std::string is a mutable value type: copying it makes an independent value, while references can alias the same string. GDScript String has value semantics and replacement methods return a new value. C++ mutation methods and GDScript returned-value methods…

    C++
    1#include <iostream>2#include <string>3#include <algorithm>4int main() { std::string s="a-b-a",t=s; std::replace(t.begin(),t.end(),'-','/'); std::cout << s << " " << t << '\n'; }
    GDScript
    1extends Node2
    3func _ready() -> void:4	var s: String = "a-b-a"5	var t: String = s.replace("-","/")6	print(s," ",t)
  5. Scripts as Classes

    C++ classes can be stored by value or accessed through pointers and references; value assignment usually copies according to the type copy operations. GDScript ordinary class-instance assignment shares a reference. A GDScript file defines a script class…

    C++
    1#pragma once2#include <string>3struct Token { std::string text="blue"; };
    GDScript
    1class_name DemoToken2extends RefCounted3var text: String = "blue"
  6. Inheritance and Super

    C++ supports multiple class inheritance and marks dynamically dispatched base methods virtual; override checks the intended override. GDScript scripts have one direct base and ordinary instance methods can be overridden without virtual. Use super to invoke…

    C++
    1#pragma once2#include <string>3struct Base { virtual ~Base()=default; virtual std::string label() const { return "base"; } };
    GDScript
    1class_name DemoBase2extends RefCounted3func label() -> String:4	return "base"

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

More courses for C++ developers

Learn GDScript from another language

Frequently asked questions

Who is GDScript for C++ Developers for?

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

Do I need to know GDScript already?

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

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

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

What does GDScript for C++ Developers cover?

The course is organized into chapters covering: Scripts and Scalar Values, Flow and Functions, Collection Ownership, Text and Callable Values, and more.

Is GDScript for C++ 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 GDScript for C++ Developers for free

Get started