<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jumana Bohra</title>
    <description>The latest articles on DEV Community by Jumana Bohra (@jumana).</description>
    <link>https://dev.to/jumana</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F344708%2F634c98ee-ac8e-4615-bacf-fdc6d59425b1.jpg</url>
      <title>DEV Community: Jumana Bohra</title>
      <link>https://dev.to/jumana</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jumana"/>
    <language>en</language>
    <item>
      <title>Strongly Typed Enum</title>
      <dc:creator>Jumana Bohra</dc:creator>
      <pubDate>Sun, 29 Mar 2020 05:18:49 +0000</pubDate>
      <link>https://dev.to/jumana/strongly-typed-enum-1khh</link>
      <guid>https://dev.to/jumana/strongly-typed-enum-1khh</guid>
      <description>&lt;p&gt;Enum is a user-defined datatype. It is a set of integral constants termed as enumerators.&lt;/p&gt;

&lt;p&gt;Enum has a limitation. Two enum in a scope cannot have same enumerators. To remove this limitation, C++11 introduced Strongly Typed Enum. Strongly Typed Enum allows you to have enumerators which can be redundant from any other enum. In declaration, a keyword 'class' is added after enum to specify it is a strongly typed enum.&lt;/p&gt;

&lt;p&gt;syntax: enum class user-definedDatatype { ....};&lt;/p&gt;

&lt;p&gt;Strongly typed enum, provides flexibility at the cost that it has to be used with scope resolution. The surrounding gets corrupted because of redundant enumerators. Hence it is a compilation error to declare or use strongly typed enum without scope resolution. Attached snippet will make it clear&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1lhkvg7C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nb21og0n2swb4chvxetb.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1lhkvg7C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nb21og0n2swb4chvxetb.JPG" alt="Snippet describing STE"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Snippet of the same code to copy and try:&lt;/p&gt;

&lt;p&gt;using namespace std;&lt;br&gt;
int main(){&lt;br&gt;
    enum class colors { red, blue, aquamarine, yellow };&lt;br&gt;
    enum class PrimaryColors { green, blue, red }; &lt;br&gt;
    enum SecondaryColors { magenta, yellow, cyan };&lt;br&gt;
    enum trafficlights { red, /*yellow, */ green }; //yellow is redundant&lt;br&gt;
    SecondaryColors sc = yellow; &lt;br&gt;
//  colors r = red; &lt;br&gt;
    colors r = colors::red;&lt;br&gt;
}&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>stl</category>
      <category>enum</category>
      <category>library</category>
    </item>
    <item>
      <title>Something I learnt more about const keyword</title>
      <dc:creator>Jumana Bohra</dc:creator>
      <pubDate>Fri, 06 Mar 2020 05:03:06 +0000</pubDate>
      <link>https://dev.to/jumana/something-i-learn-more-about-const-keyword-1em6</link>
      <guid>https://dev.to/jumana/something-i-learn-more-about-const-keyword-1em6</guid>
      <description>&lt;p&gt;const keyword has multiple usages in c++ as per the position of the keyword. While going through my project code const captured my attention again, being placed at the end of function declaration. Something like this: &lt;/p&gt;

&lt;p&gt;ReturnType FunctionName (FormalParameters...) const;&lt;/p&gt;

&lt;p&gt;While discovering its use case I found it quite helpful. This type of function is called a "const function". Such function restricts changing it's class variable inside it. It is a compilation error for const function to change it's member class variable. &lt;/p&gt;

&lt;p&gt;Well the restriction can be loosened by the storage class specifier mutable. However it can be used efficiently for getter methods.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TgMtlMzK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/havmej8lxfdrhq8lfn3m.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TgMtlMzK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/havmej8lxfdrhq8lfn3m.JPG" alt="Compiler error"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>const</category>
      <category>learning</category>
      <category>new</category>
    </item>
  </channel>
</rss>
