What does "generate const class"?

Simple question, searching for this keyword “const” give me many page about “construction” so i cant find information about this, what does the checkbox “generate const class” do in the class setting panel?

I’m also trying to figure out what this is. If you have found out, could you please explain or lead me to right direction? :slight_smile:

haha, i asked this the 27 october 2015 and i still dont know what it does :o

good luck for your search, take the direction you want :slight_smile:

I believe that in this context it is the same as declaring something “const” as in C and C++. I’m going to assume here, that it means the class have unchanging values. Perhaps this Wikipedia Article on the subject may help.

Const (Computer Programming)

What I understood from Const Functions in C++, if we check that box, we won’t be able to change any variables of the blueprint in realtime?! I’ll give it a try and reply back.

Thanks.

lol thanks :slight_smile:

All properties and functions in this class are const and should be exported as const. This flag is inherited by subclasses.

Unreal Engine 4.9 Documentation

1 Like

Its related with pure c++ knowledge.

Construction are not related with const.

Const means your intention is not to change anything.
If its marking variable → You dont want to change variable.

int x = 5;
x = 6; // you can do this

const int y = 10;
y = 15; // ERROR: You marked it with const.

If its marking function → You dont want to change member anything in the class inside of function.

class SomeClass
{
public:
  SomeClass(); // EXTRA answer : This is CONSTRUCTOR which is not related with const.

  void DoSomething()
  {
      a = 15; // You can do it.
  }

  void DoSomethingElse() const
  {
     a = 15; // ERROR : Nope you cant do it. Because you marked function with const.
  }


private:
  int a = 10;
}

If its marking class -> You dont want to change anything in class. But its not logical in c++ terminology.

Constructor on the other hand something you can use to construct your object, which you can see the example above. There are different types and implementations of it. Which I dont need to dive into that topic here.

From the documentation when a class is marked as const (short for constant)

“All properties and functions in this class are const and are exported as const. This Specifier is inherited by subclasses.”