This is a c++ variable declaration grammar question.

Asked 2 years ago, Updated 2 years ago, 26 views

Question code

const std::vector<const char*> checkList = {
"midi_null_data"
};

Question contents

When declaring a variable called checkList, I understand const at the beginning, but I don't understand why the vector data type contains const again.

I wonder what you mean by the sample code related to midi communication.

c++

2022-09-22 18:17

1 Answers

I don't know if it's accurate, but I'll answer it first.

First of all, the reason why the keyword const is added in front of it is a function that prevents modifying the original value of .

Here, vector const means that you do not want to change the source of the value of one container that stores the address of the const char.

And the data that one container is holding is a pointer called char.

So I think the reason why the character pointer has a const in front of it is to not modify the string when approaching the original.

I'm also a beginner


2022-09-22 18:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.