|
I could not understand what you said>
don't you think i need some sort of loop because i don't know how many objects
are stored in Stocks??
something like(i know this thing cannot work)
ostream& operator << (ostream& s, Stocks& stocks)
{
for(int i = 0; i <15; i++ )
return s << stocks.getStock(i)<
|
|
|
|
|
Yes, you do need a loop. That's what I meant by "for each Stock".
I can't tell you how to implement the loop because I don't know what sort of array you are using to store the Stock items. If it is a simple C array, then you can just use a loop with a counter:
for (int viItem = 0; viItem < m_iStockCount; ++viItem)
{
s << m_aStocks[viItem];
}
Also, you may want to have a closer look at Christian Graus' comment below because I have to admit to not knowing more than the very basics of ostream.
You might also want to have a good read of a good book on C++/C if the concepts of arrays is beyond your knowledge, because you're not going to get very far without it.
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
how can you return s???
because if you return s you will only return the last value that s took in the last time thru the loop?
you know what i mean ?
like this bad code:
ostream& operator << (ostream& s, Investors& investors)
{
for(int i; i<investors.getNumOfInvestors(); i++)
{
s << investors.getInvestor(i)<<endl;
}
return s;
}
remember this is only a friend method and it only takes 2 argduments
ostream& operator << (ostream& s, Investors& investors)
|
|
|
|
|
Marwan wrote:
because if you return s you will only return the last value that s took in the last time thru the loop?
s is an ostream, and you should return the same stream that was given as a parameter. Your code isn't bad, returning s after the loop is the what the << operator should do.
|
|
|
|
|
I'm not sure what you're thinking of here, but the reason you return s is shown in your code:
s << investors.getInvestor(i)<
|
|
|
|
|
Additionally, this code is only a rudimentary version of what you want. You should also check the stream state, create an instance of an object whose name escapes me right now to take care of prefix and postfix operations, and also if you want formatting to work with this object, you should stream the data to an ostringstream first and pass it to the ostream all in one operation.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
This code would be a lot faster if you had a grow policy instead of copying the whole array every time you add 1 element. It would also probably be faster to use memcpy to copy the old array into the new one. Also, you should use the prefix ++ operator whenever you don't actually need the postfix one.
The line 'investorsList = temp' makes both point to the same list, which you then call delete on at the end. So investorsList then points to an array that has been deleted.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
dude, how did you manage to screw up the indentation that much?
Anyway, the code looks fine to me (you should uncomment delete [] investorsList; , and you really don't need a temporary array, but that shouldn't hurt it for now). Things unknown: is numOfInvestors being properly initialized? And what effect does insertionSort() have (is this a library funtion? i don't recognize i'm afraid...)?
farewell goodnight last one out turn out the lights Smashing Pumpkins, Tales of a Scorched Earth
|
|
|
|
|
He must have found it - he deleted the question...
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
That's good. My answer looks less wrong this way
farewell goodnight last one out turn out the lights Smashing Pumpkins, Tales of a Scorched Earth
|
|
|
|
|
|
It's kind of annoying for people to come along and read the answers but not the question. If you leave your question up, it means others can benefit from it, even if you found the answer.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
ok sorry about that Christian!
i will never do it again!
|
|
|
|
|
Let's say I do I search for schools on yahoo. How can I click the
next button on yahoo to continue searching for schools? I want
to store the schools I find and continue searching? Any ideas?
|
|
|
|
|
If the system uses querystrings, you could devise an app to pass the data to the server automatically be altering the querystring variables each time.
Simon
"The more I learn, the more I realize I don't know" - Colin Davies
Sonork ID 100.10024
|
|
|
|
|
write your own search engine in perl (about 5 lines)
|
|
|
|
|
I have tried the CTrayNotifyIcon in a fresh skeleton mdi app and the icon in the system tray appears as well
as the task bar which is not correct.
Has anyone either
[1] - got it to work correctly with an mdi app
or
[2] - experienced the same problems
I just want to get it going quickly.
|
|
|
|
|
CTrayNotifyIcon is only for adding the icon. If you dont want your app to show on the task bar you'd have to use your own techniques to avoid that.
Nish
Nish was here, now Nish has gone;
He left his soul, to turn you on;
Those who knew Nish, knew him well;
Those who didn't, can go to hell.
I like to on the Code Project
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
... like ShowWindow(SW_HIDE) on the CMainFrame based class.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Hi,
In my application. I have a combobox.
But some items names are too long to be completly displayed.
Is it a way to display the full string, regardless of the CombBox width ?
I mean the drop down window should be greater than the width of the combobox itself.
Thanks,
Stephane
Stephane
www.exotk.org
|
|
|
|
|
Find the width of the longest string in pixels. Add the width of the borders (use GetSystemMetrics(SM_CXEDGE)*2 ) & then use SetDroppedWidth() (MFC) to set the dropdown width.
farewell goodnight last one out turn out the lights Smashing Pumpkins, Tales of a Scorched Earth
|
|
|
|
|
You could probably adapt one of the many Tool Tip classes to do the job.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Hi,
I am currently learning VC++ and MFC. I use Visual Studio 6 Enterprise and Sams: Teach Yourself Visual C++ 6 in 21 Days. I was wondering if it was worth it to save money and buy a standalone VC++.Net. Would I have many things that could be usefull to me, and my big question: Do the looks of the apps that you create with .Net look like Office XP Automatically.
// JS Paquet
cout << "Thank you all" << endl;
|
|
|
|
|
No, to do that you need to get a library like the Xtreme Toolkit ( www,codejock.com ).
The good news is it works with VC6 and is a LOT cheaper than .NET
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
i have just installed the .net framework on my PC. I had expected it to add a project type, or controls, or something, but as yet i cannot see what the installation has done other than take up my harddrive space.
Can someone enlighten me please?
==================================================
When Your Mind Wonders...Where Does It Go???
|
|
|
|