{"id":229660,"date":"2024-07-04T05:52:22","date_gmt":"2024-07-04T05:52:22","guid":{"rendered":"https:\/\/namso-gen.co\/blog\/?p=229660"},"modified":"2024-07-04T05:52:22","modified_gmt":"2024-07-04T05:52:22","slug":"how-to-assign-an-enum-value-in-c","status":"publish","type":"post","link":"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/","title":{"rendered":"How to assign an enum value in C++?"},"content":{"rendered":"<p>Enums, short for enumerations, are user-defined data types in C++ that provide a set of named values. They are often used to create a list of constant values that can be easily managed and referenced within a program. When it comes to assigning a value to an enum in C++, there are a few different approaches you can take. In this article, we will explore these approaches and provide a step-by-step guide on assigning enum values in C++.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_62 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#Assigning_an_Enum_Value\" title=\"Assigning an Enum Value\">Assigning an Enum Value<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#Implicit_Assignment\" title=\"Implicit Assignment:\">Implicit Assignment:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#Explicit_Assignment\" title=\"Explicit Assignment:\">Explicit Assignment:<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#FAQs_about_Enum_Value_Assignment_in_C\" title=\"FAQs about Enum Value Assignment in C++\">FAQs about Enum Value Assignment in C++<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#1_Can_an_enum_have_duplicate_values\" title=\"1. Can an enum have duplicate values?\">1. Can an enum have duplicate values?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#2_Can_an_enum_have_negative_values\" title=\"2. Can an enum have negative values?\">2. Can an enum have negative values?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#3_Can_an_enum_have_floating-point_values\" title=\"3. Can an enum have floating-point values?\">3. Can an enum have floating-point values?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#4_Can_you_assign_non-integer_values_to_an_enum\" title=\"4. Can you assign non-integer values to an enum?\">4. Can you assign non-integer values to an enum?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#5_Can_you_assign_the_same_value_to_multiple_enumerators\" title=\"5. Can you assign the same value to multiple enumerators?\">5. Can you assign the same value to multiple enumerators?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#6_Can_you_assign_a_value_outside_the_integer_range_to_an_enum\" title=\"6. Can you assign a value outside the integer range to an enum?\">6. Can you assign a value outside the integer range to an enum?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#7_Can_you_change_the_assigned_value_of_an_enum\" title=\"7. Can you change the assigned value of an enum?\">7. Can you change the assigned value of an enum?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#8_Can_you_assign_values_to_an_enum_dynamically_during_runtime\" title=\"8. Can you assign values to an enum dynamically during runtime?\">8. Can you assign values to an enum dynamically during runtime?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#9_Can_you_assign_a_default_value_to_an_enum\" title=\"9. Can you assign a default value to an enum?\">9. Can you assign a default value to an enum?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#10_Can_you_use_variables_to_assign_values_to_an_enum\" title=\"10. Can you use variables to assign values to an enum?\">10. Can you use variables to assign values to an enum?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#11_Can_you_assign_a_string_to_an_enum\" title=\"11. Can you assign a string to an enum?\">11. Can you assign a string to an enum?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#12_Can_you_assign_the_same_name_to_multiple_enumerators_within_different_enums\" title=\"12. Can you assign the same name to multiple enumerators within different enums?\">12. Can you assign the same name to multiple enumerators within different enums?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Assigning_an_Enum_Value\"><\/span>Assigning an Enum Value<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Assigning a value to an enum in C++ can be done in two primary ways: implicit and explicit assignment.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Implicit_Assignment\"><\/span><b>Implicit Assignment:<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nIn C++, enums are like integer values by default, where the first enumerator is initialized with 0, the second with 1, and so on. Each subsequent enumerator is assigned a value one greater than the previous.<\/p>\n<p>Consider the following example:<\/p>\n<p><code><br \/>\nenum Color {<br \/>\n    RED, \/\/ assigned 0<br \/>\n    BLUE, \/\/ assigned 1<br \/>\n    GREEN \/\/ assigned 2<br \/>\n};<br \/>\n<\/code><\/p>\n<p>In the above example, the enum <code>Color<\/code> implicitly assigns the values 0, 1, and 2 to the enumerator <code>RED<\/code>, <code>BLUE<\/code>, and <code>GREEN<\/code> respectively.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Explicit_Assignment\"><\/span><b>Explicit Assignment:<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nYou can also assign specific values to enum elements explicitly. You can assign any values you want to each element, and subsequent elements will continue from the last assigned value.<\/p>\n<p>Take a look at the following code snippet:<\/p>\n<p><code><br \/>\nenum Direction {<br \/>\n    NORTH = 10, \/\/ explicitly assigned 10<br \/>\n    EAST, \/\/ assigned 11<br \/>\n    SOUTH = 20, \/\/ explicitly assigned 20<br \/>\n    WEST \/\/ assigned 21<br \/>\n};<br \/>\n<\/code><\/p>\n<p>In the above example, the enum <code>Direction<\/code> explicitly assigns the values 10, 11, 20, and 21 to the enumerators <code>NORTH<\/code>, <code>EAST<\/code>, <code>SOUTH<\/code>, and <code>WEST<\/code> respectively. <\/p>\n<h2><span class=\"ez-toc-section\" id=\"FAQs_about_Enum_Value_Assignment_in_C\"><\/span>FAQs about Enum Value Assignment in C++<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"1_Can_an_enum_have_duplicate_values\"><\/span><b>1. Can an enum have duplicate values?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nNo, enums cannot have duplicate values. Each enumerator within an enum must have a unique value.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"2_Can_an_enum_have_negative_values\"><\/span><b>2. Can an enum have negative values?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nYes, an enum can have negative values. Enums in C++ are essentially integer values, so they can be both positive and negative.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"3_Can_an_enum_have_floating-point_values\"><\/span><b>3. Can an enum have floating-point values?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nNo, enums cannot have floating-point values. They are restricted to integer values only.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"4_Can_you_assign_non-integer_values_to_an_enum\"><\/span><b>4. Can you assign non-integer values to an enum?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nNo, non-integer values cannot be directly assigned to an enum. However, you can use type casting to assign non-integer values to an enum.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"5_Can_you_assign_the_same_value_to_multiple_enumerators\"><\/span><b>5. Can you assign the same value to multiple enumerators?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nYes, you can assign the same value to multiple enumerators, but it is generally not recommended as it might cause confusion and unintended behavior in your code.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"6_Can_you_assign_a_value_outside_the_integer_range_to_an_enum\"><\/span><b>6. Can you assign a value outside the integer range to an enum?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nEnums in C++ are integer values, so they must fall within the valid integer range. Assigning a value outside the valid range will result in compiler errors.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"7_Can_you_change_the_assigned_value_of_an_enum\"><\/span><b>7. Can you change the assigned value of an enum?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nThe assigned value of an enum remains constant within the scope of the program. It cannot be changed during program execution.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"8_Can_you_assign_values_to_an_enum_dynamically_during_runtime\"><\/span><b>8. Can you assign values to an enum dynamically during runtime?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nNo, enum values are determined at compile-time and cannot be assigned or modified dynamically during runtime.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"9_Can_you_assign_a_default_value_to_an_enum\"><\/span><b>9. Can you assign a default value to an enum?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nYes, you can assign a default value to an enum. By default, if you do not assign any values to the enumerators, the first enumerator will be assigned 0, the second 1, and so on.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"10_Can_you_use_variables_to_assign_values_to_an_enum\"><\/span><b>10. Can you use variables to assign values to an enum?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nNo, you cannot use variables to assign values to an enum. The values assigned to enumerators must be constant expressions.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"11_Can_you_assign_a_string_to_an_enum\"><\/span><b>11. Can you assign a string to an enum?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nNo, you cannot directly assign a string to an enum. However, you can use an enum to create a mapping between strings and their corresponding values.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"12_Can_you_assign_the_same_name_to_multiple_enumerators_within_different_enums\"><\/span><b>12. Can you assign the same name to multiple enumerators within different enums?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\nYes, you can assign the same name to multiple enumerators within different enums. The scope of an enum is limited to the enum in which it is defined.<\/p>\n<p>In conclusion, assigning a value to an enum in C++ can be done implicitly or explicitly. Implicit assignment follows a sequence of integer values starting from 0, while explicit assignment allows you to assign specific values to each enumerator. By understanding these enum assignment techniques, you can easily manage and work with enum values in your C++ programs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Enums, short for enumerations, are user-defined data types in C++ that provide a set of named values. They are often used to create a list of constant values that can be easily managed and referenced within a program. When it comes to assigning a value to an enum in C++, there are a few different &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"How to assign an enum value in C++?\" class=\"read-more button\" href=\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#more-229660\">Read more<span class=\"screen-reader-text\">How to assign an enum value in C++?<\/span><\/a><\/p>\n","protected":false},"author":57,"featured_media":107420,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[86279],"tags":[],"class_list":["post-229660","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-learn","no-featured-image-padding"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to assign an enum value in C++?<\/title>\n<meta name=\"description\" content=\"Enums, short for enumerations, are user-defined data types in C++ that provide a set of named values. They are often used to create a list of constant\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to assign an enum value in C++?\" \/>\n<meta property=\"og:description\" content=\"Enums, short for enumerations, are user-defined data types in C++ that provide a set of named values. They are often used to create a list of constant\" \/>\n<meta property=\"og:url\" content=\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/\" \/>\n<meta property=\"og:site_name\" content=\"Namso Gen Blog - Free Credit Card Generator [100% Valid]\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/synchronyfinancial\" \/>\n<meta property=\"article:published_time\" content=\"2024-07-04T05:52:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/namso-gen.co\/blog\/wp-content\/uploads\/2024\/03\/faq.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Casey Mayer\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@synchrony\" \/>\n<meta name=\"twitter:site\" content=\"@synchrony\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Casey Mayer\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/\"},\"author\":{\"name\":\"Casey Mayer\",\"@id\":\"https:\/\/namso-gen.co\/blog\/#\/schema\/person\/89e431077ef417dfaa131f435124f18f\"},\"headline\":\"How to assign an enum value in C++?\",\"datePublished\":\"2024-07-04T05:52:22+00:00\",\"dateModified\":\"2024-07-04T05:52:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/\"},\"wordCount\":662,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/namso-gen.co\/blog\/#organization\"},\"articleSection\":[\"Learn\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/\",\"url\":\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/\",\"name\":\"How to assign an enum value in C++?\",\"isPartOf\":{\"@id\":\"https:\/\/namso-gen.co\/blog\/#website\"},\"datePublished\":\"2024-07-04T05:52:22+00:00\",\"dateModified\":\"2024-07-04T05:52:22+00:00\",\"description\":\"Enums, short for enumerations, are user-defined data types in C++ that provide a set of named values. They are often used to create a list of constant\",\"breadcrumb\":{\"@id\":\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/namso-gen.co\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to assign an enum value in C++?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/namso-gen.co\/blog\/#website\",\"url\":\"https:\/\/namso-gen.co\/blog\/\",\"name\":\"Namso Gen Blog - Free Credit Card Generator [100% Valid]\",\"description\":\"In Namso gen blog you can get many tips regarding to Credit cards, VCC, Credit card security etc. You can generate credit cards by using Namso-gen.co\",\"publisher\":{\"@id\":\"https:\/\/namso-gen.co\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/namso-gen.co\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/namso-gen.co\/blog\/#organization\",\"name\":\"Namso Gen Blog - Free Credit Card Generator [100% Valid]\",\"url\":\"https:\/\/namso-gen.co\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/namso-gen.co\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/namso-gen.co\/blog\/wp-content\/uploads\/2020\/07\/namso-gen-logo.png\",\"contentUrl\":\"https:\/\/namso-gen.co\/blog\/wp-content\/uploads\/2020\/07\/namso-gen-logo.png\",\"width\":500,\"height\":164,\"caption\":\"Namso Gen Blog - Free Credit Card Generator [100% Valid]\"},\"image\":{\"@id\":\"https:\/\/namso-gen.co\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/synchronyfinancial\",\"https:\/\/twitter.com\/synchrony\",\"https:\/\/www.youtube.com\/synchronyfinancial\",\"https:\/\/www.instagram.com\/synchrony\",\"https:\/\/www.linkedin.com\/company\/synchrony-financial\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/namso-gen.co\/blog\/#\/schema\/person\/89e431077ef417dfaa131f435124f18f\",\"name\":\"Casey Mayer\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/namso-gen.co\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g\",\"caption\":\"Casey Mayer\"},\"description\":\"Guest author Casey Mayer has meticulously crafted and revised this article to the best of their knowledge and understanding. Readers are strongly advised to exercise caution, verify information independently, and rely on their own judgment when considering the information provided. Read more articles on Namso Gen here.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to assign an enum value in C++?","description":"Enums, short for enumerations, are user-defined data types in C++ that provide a set of named values. They are often used to create a list of constant","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/","og_locale":"en_US","og_type":"article","og_title":"How to assign an enum value in C++?","og_description":"Enums, short for enumerations, are user-defined data types in C++ that provide a set of named values. They are often used to create a list of constant","og_url":"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/","og_site_name":"Namso Gen Blog - Free Credit Card Generator [100% Valid]","article_publisher":"https:\/\/www.facebook.com\/synchronyfinancial","article_published_time":"2024-07-04T05:52:22+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/namso-gen.co\/blog\/wp-content\/uploads\/2024\/03\/faq.png","type":"image\/png"}],"author":"Casey Mayer","twitter_card":"summary_large_image","twitter_creator":"@synchrony","twitter_site":"@synchrony","twitter_misc":{"Written by":"Casey Mayer","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#article","isPartOf":{"@id":"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/"},"author":{"name":"Casey Mayer","@id":"https:\/\/namso-gen.co\/blog\/#\/schema\/person\/89e431077ef417dfaa131f435124f18f"},"headline":"How to assign an enum value in C++?","datePublished":"2024-07-04T05:52:22+00:00","dateModified":"2024-07-04T05:52:22+00:00","mainEntityOfPage":{"@id":"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/"},"wordCount":662,"commentCount":0,"publisher":{"@id":"https:\/\/namso-gen.co\/blog\/#organization"},"articleSection":["Learn"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/","url":"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/","name":"How to assign an enum value in C++?","isPartOf":{"@id":"https:\/\/namso-gen.co\/blog\/#website"},"datePublished":"2024-07-04T05:52:22+00:00","dateModified":"2024-07-04T05:52:22+00:00","description":"Enums, short for enumerations, are user-defined data types in C++ that provide a set of named values. They are often used to create a list of constant","breadcrumb":{"@id":"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/namso-gen.co\/blog\/how-to-assign-an-enum-value-in-c\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/namso-gen.co\/blog\/"},{"@type":"ListItem","position":2,"name":"How to assign an enum value in C++?"}]},{"@type":"WebSite","@id":"https:\/\/namso-gen.co\/blog\/#website","url":"https:\/\/namso-gen.co\/blog\/","name":"Namso Gen Blog - Free Credit Card Generator [100% Valid]","description":"In Namso gen blog you can get many tips regarding to Credit cards, VCC, Credit card security etc. You can generate credit cards by using Namso-gen.co","publisher":{"@id":"https:\/\/namso-gen.co\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/namso-gen.co\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/namso-gen.co\/blog\/#organization","name":"Namso Gen Blog - Free Credit Card Generator [100% Valid]","url":"https:\/\/namso-gen.co\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/namso-gen.co\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/namso-gen.co\/blog\/wp-content\/uploads\/2020\/07\/namso-gen-logo.png","contentUrl":"https:\/\/namso-gen.co\/blog\/wp-content\/uploads\/2020\/07\/namso-gen-logo.png","width":500,"height":164,"caption":"Namso Gen Blog - Free Credit Card Generator [100% Valid]"},"image":{"@id":"https:\/\/namso-gen.co\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/synchronyfinancial","https:\/\/twitter.com\/synchrony","https:\/\/www.youtube.com\/synchronyfinancial","https:\/\/www.instagram.com\/synchrony","https:\/\/www.linkedin.com\/company\/synchrony-financial"]},{"@type":"Person","@id":"https:\/\/namso-gen.co\/blog\/#\/schema\/person\/89e431077ef417dfaa131f435124f18f","name":"Casey Mayer","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/namso-gen.co\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g","caption":"Casey Mayer"},"description":"Guest author Casey Mayer has meticulously crafted and revised this article to the best of their knowledge and understanding. Readers are strongly advised to exercise caution, verify information independently, and rely on their own judgment when considering the information provided. Read more articles on Namso Gen here."}]}},"_links":{"self":[{"href":"https:\/\/namso-gen.co\/blog\/wp-json\/wp\/v2\/posts\/229660","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/namso-gen.co\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/namso-gen.co\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/namso-gen.co\/blog\/wp-json\/wp\/v2\/users\/57"}],"replies":[{"embeddable":true,"href":"https:\/\/namso-gen.co\/blog\/wp-json\/wp\/v2\/comments?post=229660"}],"version-history":[{"count":0,"href":"https:\/\/namso-gen.co\/blog\/wp-json\/wp\/v2\/posts\/229660\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/namso-gen.co\/blog\/wp-json\/wp\/v2\/media\/107420"}],"wp:attachment":[{"href":"https:\/\/namso-gen.co\/blog\/wp-json\/wp\/v2\/media?parent=229660"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/namso-gen.co\/blog\/wp-json\/wp\/v2\/categories?post=229660"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/namso-gen.co\/blog\/wp-json\/wp\/v2\/tags?post=229660"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}