Telegram Group & Telegram Channel
Что лучше const или define?

Ответ:
define - это директива препроцессора, которая не учитывает ни типов, ни областей видимости. Препроцессор вставляет значение везде, где оно используется и создается множество копий 3.14159265359 в объектном коде, константа никогда не порождает больше одной копии этого значения. define трудно отлаживать, потому что у него нет имени, только магическое число, нельзя взять адрес или создать ссылку на это значение.

У const есть тип, область видимости, можно взять адрес, создать константную ссылку на эту переменную.

Определенно, лучше использовать const, а не define.

➡️ @cpp_geek



tg-me.com/cpp_geek/243
Create:
Last Update:

Что лучше const или define?

Ответ:
define - это директива препроцессора, которая не учитывает ни типов, ни областей видимости. Препроцессор вставляет значение везде, где оно используется и создается множество копий 3.14159265359 в объектном коде, константа никогда не порождает больше одной копии этого значения. define трудно отлаживать, потому что у него нет имени, только магическое число, нельзя взять адрес или создать ссылку на это значение.

У const есть тип, область видимости, можно взять адрес, создать константную ссылку на эту переменную.

Определенно, лучше использовать const, а не define.

➡️ @cpp_geek

BY C++ geek




Share with your friend now:
tg-me.com/cpp_geek/243

View MORE
Open in Telegram


telegram Telegram | DID YOU KNOW?

Date: |

That growth environment will include rising inflation and interest rates. Those upward shifts naturally accompany healthy growth periods as the demand for resources, products and services rise. Importantly, the Federal Reserve has laid out the rationale for not interfering with that natural growth transition.It's not exactly a fad, but there is a widespread willingness to pay up for a growth story. Classic fundamental analysis takes a back seat. Even negative earnings are ignored. In fact, positive earnings seem to be a limiting measure, producing the question, "Is that all you've got?" The preference is a vision of untold riches when the exciting story plays out as expected.

The Singapore stock market has alternated between positive and negative finishes through the last five trading days since the end of the two-day winning streak in which it had added more than a dozen points or 0.4 percent. The Straits Times Index now sits just above the 3,060-point plateau and it's likely to see a narrow trading range on Monday.

telegram from it


Telegram C++ geek
FROM USA