Ok, I am a little confused as to why this is not working. The code I am going to post is all I have right now, but it is part of a larger program I plan to build. I cant get started on my larger project until I finish my class header file. The only problem is, I cant get my class to work correctly. It worked almost perfect...until I made made the class have private variables and public functions. I know you are supposed to do this, but I cant seem to get it to work.
And the output looks like:Code://Class Music #include<iostream> class m { public: void SetGroup(char[]); char Get(); private: char group[50]; struct cds { char title[]; struct songs { char songName[]; char lyrics[]; }; songs song[25]; }; cds cd[50]; }; void m::SetGroup(char igroup[]) { group[50] = igroup[50]; std::cout<<igroup<<'\n'<<group; } char m::Get() { return group[50]; } int main() { m music[3]; char hey[] = "Senses Fail"; music[0].SetGroup(hey); // std::cout<<music[0].Get(); system("PAUSE"); return 0; }
Senses Fail
╨ⁿ"Press any key to continue . . .
I am confused as to why the value is passed, but not assigned to the class variable. Because I havent gotten this part to work, I havent worried about the Get function. I already see a problem. Can I return a char array? Would char m::Get() return a char array, because I tryed it with char[] m::Get() and that didnt work, so I am a little confused as to what to to about that. But I am not really there yet. I cant even assign the class variable the right value.
Thanks for any help provided.
-Ep




Reply With Quote