|
-
September 18th, 2005, 11:02 AM
#1
Why enum works so strange? :/
look, this program print:
1 640x480
2 800x640
3 1600x1200
I thought I would get:
low 640x480
medium 800x640
hight 1600x1200
Why it print numbers?
I am new at this forum and don't know how to use tags for code. Where is it?
This is program:
#include <stdio.h>
#include <iostream>
#include <fstream>
using namespace std;
enum resolution {low,medium,hight};
//class
class display{
int width,height;
resolution res;
public:
void set(int w,int h){width=w; height=h;}
void get(int &w,int &h){w=width; h=height;}
void setR(resolution r){res=r;}
resolution getR(){return res;}
};
//array
char names[3][7]= {"low", "medium" , "hight"};
int main(){
display dm[3];
int i,w,h;
dm[0].set(640,480);
dm[1].set(800,600);
dm[2].set(1600,1200);
dm[0].setR(low);
dm[1].setR(medium);
dm[2].setR(hight);
cout<<"We have:"<<endl;
for(int i=0;i<3;i++){
dm[i].get(w,h);
cout<<dm[i].getR()<<" "<<w<<"x"<<h<<endl;
}
return 0;
}
P.S. Need your advice.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|