|
Music is another class, but Band.cpp as the music list, so show_available_music its implemented here .
My question is how do I call show_available_music from Main.cpp.
"Failure is always an option."
|
|
|
|
|
FrankMookie wrote: My question is how do I call show_available_music from Main.cpp.
Since it is not a static member, you'll need to call it in the context of a Band object.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
But if I call it in the context of a Band object, it will only display the correspondent objects of that particular band... and I want the list of all band's musics...
"Failure is always an option."
|
|
|
|
|
Your Band class implies a single band. Therefore, it only makes sense that it would only know about its own music. Perhaps you need a collection of Band objects.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Yes, you are right. Thats my problem. I have a similar function that shows all the bands in a list.
I'm able to show all the musics from a band... I use: band->show_availavle__music() This gives me the music from that specific band.
But I want an option to show all the musics from all the bands. I mean, all the objects( music) from all the correspondent objects (band).
"Failure is always an option."
|
|
|
|
|
FrankMookie wrote: I have a similar function that shows all the bands in a list.
Then use the returned Band object from that function to call the Band::show_availavle__music() function.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I'm not sure i understand that.. Can you give me an example?
This is the code I have to display the music from ONE specific Band :
Main.cpp
cout<<"Whats the name of the band you want to search music from? ";
fflush(stdin); getline(cin,name);
band = myManager.select_band_name(name);
if(band!=0)
{
system("cls");
cout << "List of " << name <<"'s music.\n" << endl;
band->show_available_music();
}
Band.cpp
void Band::show_available_music()
{
list<Music>::iterator it;
for ( it=available_music_list.begin() ; it != available_music_list.end(); it++ )
cout << *it << endl;
}
"Failure is always an option."
|
|
|
|
|
But what of the function you mentioned that "shows all the bands in a list?" Much like select_band_name() returns a single Band object, you need a function that returns a Band object based on an index or an iterator. That way you could use it in a loop.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Ok.. I see what you mean. I'll try to do a loop. Thank you so much.
"Failure is always an option."
|
|
|
|
|
Hello again,
I have a lab assignment in my C++ class that asks me to do the following:
-Create an application that prompts the user for two 3-digit numbers, then display the result in the following format:
ex. 456
x 433
---------
1368
13680
182400
---------
197448
The problem I am having is the method I'm trying to use. I am using the carry over technique, and I need a way to split up the 3-digit numbers into single numbers, then multiply/carry/add accordingly
Anything unclear let me know,
Thanks!
|
|
|
|
|
You should think of an algorithm with the division ( / ) and mod ( % ) operators to split a number.
For example:
513 % 10 = 3 -> Last digit
513 / 10 = 51
51 % 10 = 1 -> Second digit
51 / 10 = 5
5 % 10 = 5 -> First digit
5 / 10 = 0 -> END
Think a bit.
|
|
|
|
|
Stewie Griffin wrote: You should think of an algorithm with the division ( / ) and mod ( % ) operators to split a number.
Yes, typically. But in this case, the program is prompting the user for the numbers so it is already in string form.
He can take the input string...
char[] n1 = "456";
...and "split the number" by accessing it character by character. Then covert each character to an int:
digit0 = n1[0] - '0';
digit1 = n1[1] - '1';
|
|
|
|
|
Robert.C.Cartaino wrote: ...the program is prompting the user for the numbers so it is already in string form.
So put them into a numeric variable (e.g., int ) instead.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I originally attempted the char[] approach, but my compiler (Dev-C++) constantly returned an error the minute I attempted to do any type of mathematical operation.
And I do actually like the algorithmic approach. I will give it a try. Thanks!
|
|
|
|
|
Hello guys,
I'm writing an MFC application that uses a splitter window - a "windows explorer" application. It is a typical windows explorer style application - it has a Treeview in the left pane for navigation, and a Frame that displays various views at different times in the right hand frame. I have a small usability problem - whenever the user opens a new dialog by interacting with the view displayed in the right hand frame, focus returns to the left hand pane (the treeview), rather than the right Frame which holds the current View, typically a Form View.
This is bad - surely focus should return to where it was lost from when the dialog was given focus - the right pane/ Form View.
I call this code from BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext) :
m_wndSplitter.SetActivePane(0, 1) ;
However, this doesn't help, or have any discernible effect. Perhaps I've misunderstood what this method does - according to MSDN documentation- http://msdn.microsoft.com/en-us/library/52afb8hs(VS.80).aspx[^] -, it "sets the pane as active", and "is called by the framework" - I guess that means it is intended that the programmer should provide their own implementation of this virtual function, so they can do house keeping when the right hand pane gets focused by the user, rather than being intended for the programmer to call directly. What should I do to achieve the desired effect of having focus return to the right hand pane?
Regards,
Sternocera
|
|
|
|
|
Sternocera wrote: I guess that means it is intended that the programmer should provide their own implementation of this virtual function, [snip] rather than being intended for the programmer to call directly.
No
"You can explicitly call SetActivePane to change the focus to the specified view."
You are probably experiencing a timing issue
"This member function is called by the framework"
You are probably calling it first and then the framework is calling it.
led mike
|
|
|
|
|
led mike wrote: You are probably experiencing a timing issue
Yes, but I'd like to have focus return to the right hand pane by default - surely there is a better way than repeatedly calling SetActivePane(), SetFocus(), or some equivalent?
|
|
|
|
|
I have this:
HANDLE hFile;
DWORD wmWritten;
char code[1024];
hFile = CreateFile(filename,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
ReadFile(hFile,code,1024,&wmWritten,NULL);
CloseHandle(hFile);
but i always get a 1024 char file, i mean if the file has more than 1024 chars then it will just show up the first 1024 of them. What should I do for getting always the exact number of chars the file will have. I mean I want a way to get the number of chars instead of just typing 50000 instead of 1024 because if i do that it ll show up iiiiiiiiiiiiiii or something like that for completing the 50000 chars if the value is lower than that.
thanks.
modified on Wednesday, August 27, 2008 5:24 PM
|
|
|
|
|
letueros wrote: What should I do for getting always the exact number of chars the file will have.
I suggest you start by learning to read the documentation[^]
led mike
|
|
|
|
|
thanks, it worked but I used GetFileSize(... for getting the DWORD value, but there seems to be something unusual though at the end of the char* it always says ýýýý««««««««îþîþîþ. Should I remove that manually i mean by replacing that by "" or substringing it or is there a better way to get rid of it?
|
|
|
|
|
letueros wrote: Should I remove that manually
No, simply put a '\0' character in the appropriate spot in code .
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hello every one,
I have one question regarding neural networks and it's functionality. I'm newbie in this field.
Actually i want to use a supervised neural network to estimate a function values at different locations.
Suppose we want to estimate y = x^2 and we have some training data to learn the network
x=1 => y=1
x=2 => y=4
x=3 => y=9
x=4 => y=16
x=5 => y=25
Now suppose we want to estimate function value at x = 10
At first it seems that Back propagation is the best network for this purpose but after i tried some source code from CodeProject i found out that Back Propagation can only estimate function values that are around the training set!(Tell me if I'm wrong!) so for example it can estimate function at x=4.5 but it cannot estimate function at x=10 (i think it will return 25)
So which type of Neural Network should i use for this purpose? Any ideas?
|
|
|
|
|
I'm trying to create some menu items dynamically in a popup menu, varying text, some of which then need check marks against them, and some need to be disabled (greyed).
This all works fine except for the disabled / greyed state.
They are created with InsertMenuItem() and everything is set up in the MENUITEMINFO struct. Everything works fine - including the check marks - except that they never come up disabled.
When I modify them with SetMenuItemInfo(), again everything fine except the disabled state.
At the end of all modifications DrawMenuBar() is called, but it doesn't seem to make any difference either way.
Any suggestions as to why?
|
|
|
|
|
Nick01223 wrote: and everything is set up in the MENUITEMINFO struct.
Can you show the code that initializes the struct?
Have you tried EnableMenuItem()?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes, didn't work either.
But, literally this minute I've fixed it.
Was using WM_MENUSELECT instead of WM_INITMENUPOPUP as the trigger for the updating. Must occur at a different time, and greying must be different to check marks, because what was happening was the greying didn't work, but if while the menu was down you quickly moved the mouse off the menu (ie off the menu window) - it rapidly updated to the greyed state. Use WM_INITMENUPOPUP and it works all the time.
Must be to do with idle time processing.
Thanks for your help.
|
|
|
|