|
Visual C++: Enumeration |
Objectives:
enum enum-type-name { enum-list } enum-variable;
|
#include "stdafx.h"
#include <iostream>
using namespace System;
using namespace std;
int main(array<System::String ^> ^args)
{
enum letters {a,b,c,d,e,f };
letters lt = a;
int i;
Console::WriteLine(L"Hello World");
for(i = lt;i < f; i++){
Console::WriteLine(i);
}
for(i = a ;i < f; i++){
//Console::WriteLine(i);
cout << "letter no : " << i << endl;
}
Console::ReadLine();
return 0;
}
|
|
 |

|
If you are not using VC++, you won't need the library and namespaces
like using namespace System; #include "stdafx.h". The namespaces are
very useful, when you have same library name but different or edited
contents. Since I was using VC++ at this moment, I need to use the header
#include "stdafx.h" to run the compiler. To exit you may need
click on "X" to close it.
|
// second_VC++.cpp : main project file.
#include "stdafx.h"
#include <iostream>
//using namespace System;
using namespace std;
//enum enum-type-name { enum-list } enum-variable;
//int main(array<System::String ^> ^args)
int main()
{
enum letters {a,b,c,d,e,f }lt;
lt = a;
int i;
//Console::WriteLine(L"Hello World");
for(i = lt;i < f; i++){
cout << "variable lt : " <<(i)<< endl;
}
for(i = a ;i < f; i++){
//Console::WriteLine(i);
cout << "letter no : " << i << endl;
}
//Console::ReadLine();
cin >>i ;
return 1;
}
|

|
| |
| |