Skip to content
This repository was archived by the owner on Apr 24, 2024. It is now read-only.

Latest commit

 

History

History
46 lines (32 loc) · 1.12 KB

constants.md

File metadata and controls

46 lines (32 loc) · 1.12 KB
description
What are constants and how to you use them in Versace.

Constants

What is a constant?

A constant is a variable that cannot be changed. It is a value that is set once and never changes. Constants are defined using the const keyword.

{% hint style="info" %} Constants must be initialized when they are defined. They cannot be initialized later in the program. {% endhint %}

{% hint style="info" %} Constants require a vaule and data type to be defined. They cannot be left undefined. {% endhint %}

Defining a constant

A constant is defined using the const keyword. The syntax is as follows:

const <data type> <name> = <value>;

Example

const int x = 5;

Constants can be used in the same way as variables. The only difference is that they cannot be changed. They can also be accessed from anywhere in the program regardless of the local namespace they were defined in.

const float x = 3.69;
out << x << "is a constant"
func somefunctions() {
    out << x << "This is calling the constant from a function";
}
somefunctions();