C++ use enumerated and , Change the value of the variable -
I have a question in "Use C ++" in my home:
Questions : Complete the following program as required in the comments, and then show the output.
#include & lt; Iostream & gt; Using std :: cout; Using std :: cin; Using the Std :: endl; // Define an enumerated datatip language // Its legal value is German, English, Spanish, and Turkish int main () {/ * Define a varaible lang of type * / / * Set the varaible lang with the value * / / * Write a statement to print the value of the violet lang * / / * Change the value of varible lang to Turkey / return 0; } // and main
-
I had written the code like this.
#include & lt; Iostream & gt; Using std :: cout; # Include & lt; Iostream & gt; Using std :: cout; Using std :: cin; Using the Std :: endl; // Define an enumerated dataTip language. Its legal value is German, English, Spanish, and Turkish language enum language {German, English, Spanish, Turkish}; Int main () {enum language {German, English, Spanish, Turkish}; / * Define a varian lang of type language * language / language; Set the WallyLange with / * Value German * / lang = german; / * Verbal lang * / COAT & lt; & Lt; Lang & lt; & Lt; Endl; Write a statement to print the value of / * Change the value of Varible lang to Turkey / lang = turkish; The court's & lt; & Lt; Lang & lt; & Lt; Endl; Return 0; } I tried to answer, but what can I do: $
This is my answer to false, I really can not understand these organs:
/ * Change the value of variable length to Turkey * / !!
I know how to solve them, can you help me, please? : $
Thanks
The assignment is written in the comment < Blockquote>
define one enumerated datatype language
so you should replace the
language
instead of the namelanguage
.In your program you have defined two enumeration with the same name, the final announcement in the functions hides the declaration with the same name in the global namespace, it is clear that to define the two enumeration There is no requirement. One of them you can remove
You can write for example
#include & lt; Iostream & gt; Enum language {German, English, Spanish, Turkish}; Int main () {/ * Define a varian lang of type language * language / language; Set the WallyLange with / * Value German * / lang = german; / * Verilame * / std :: cout & lt; & Lt; Lang & lt; & Lt; Std :: endl; / * Change the value of Varible lang to Turkey / lang = turkish; }
You can add an output statement after changing the variable length.
// ... / varible lang to Turkish * / lang = Turkey; Std :: cout & lt; & Lt; Lang & lt; & Lt; Std :: endl; }
Comments
Post a Comment