-
Enum
How should i go to get the numbers in the Frequency[] array passing by the Song[] array?
Maybe im not using the right method at all.
Code:
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
enum Note {B5,As5,A5,Gs5,G5,Fs5,F5,E5,Ds5,D5,Cs5,C5,};
double Frequency[] = {
10,20,30,40,50,60,70,80,90,100,110,120,
};
char Song[] = {Ds5,Gs5,Gs5,F5,Ds5,Gs5,Ds5,Ds5,F5,};
for(x=0; x<=9; x++) cout << Song[Note(Frequency[x])];
return 0;
}
-
What do you mean by "numbers in the Frequency[] array passing by the Song[] array"?
-
I mean the values in the Frequency[] array passing by the Song[] array.
Like if i pass Song[3] which is = Gs5 and the 4th member of enum Notes, i want to get 40, which is the also the 4th member of Frequency[].
Maybe i shouldnt use enum by the way.
-
Oh, now I understand. Since you want to print elements of the Frequency array, it is obvious that you want an expression of the form Frequency[index]. Now, index must correspond to an enumerator value, presumably obtained from the song array. Therefore, the expression should be Frequency[Song[x]].
A few other things to note: the enum should not be declared with a trailing comma. Song should be an array of Note, not char. Your loop condition is not correct.
-
Brilliant!
Thats exactly what i wanted.
I corrected everything and it works great.
Thank you very much Laserlight! :)