Skip to main content

Constructors & Destructors

C

// Not Available

Back to top

C++ (Cpp)

// Header File (MyClass.h or MyClass.hpp)
#pragma once

class MyClass
{
// Simplified Example

// ------------------------------------
// Constructor
// ------------------------------------

// The constructor has the same name as the class
// Can be omitted if you have no code to put here.
MyClass();

// You can have more than one
MyClass(int value);
MyClass(int value, float otherValue);
MyClass(char letter);
//and so on

// You can add the "explicit" keyword to avoid implicit conversion
explicit MyClass(int value);
explicit MyClass(int value, float otherValue);
explicit MyClass(char letter);

// You can also "delete" a specific constructor to remove its use
MyClass() = delete; // this constructor wont be available
};
// Header File (MyClass.h or MyClass.hpp)
#pragma once

class MyClass
{
// Simplified Example

// ------------------------------------
// Member Initializer / Member Initializer Lists
// ------------------------------------
};
// Header File (MyClass.h or MyClass.hpp)
#pragma once

class MyClass
{
// Simplified Example

// ------------------------------------
// Copy Constructor
// ------------------------------------
};
// Header File (MyClass.h or MyClass.hpp)
#pragma once

class MyClass
{
// Simplified Example

// ------------------------------------
// Move Constructor
// ------------------------------------
};
// Header File (MyClass.h or MyClass.hpp)
#pragma once

class MyClass
{
// Simplified Example

// ------------------------------------
// Desconstructor
// ------------------------------------
};

Back to top

C# (Csharp)

// TODO

Back to top

Java

// TODO

Back to top

Rust

// TODO

Back to top

Go

// TODO

Back to top

Javascript

// TODO

Back to top

Typescript

// TODO

Back to top

Python

# TODO

Back to top