|
C:\Windows\Desktop\Project2\Project.cpp(383) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type '' (or there is no acceptable conversion)
Error executing cl.exe.
here is the code!
ostream& operator << (ostream& s, Market& market)
{
for(int i = 0; i <10; i++)
{
s <<"Stock information: "<< market.stockArray[i].getCompanyName()<<" "<<market.stockarray[i].getstockticker()<<" "<<market.stockarray[i].getmarkettraded()<<"="" "<<market.stockarray[i].gettypeofmanufactr()<<"="" "<<market.stockarray[i].getinitialvalue()<<"="" "<<market.stockarray[i].getnumofoutshares<<endl;
="" return="" s;
="" }
}
<\pre="">
thanks
|
|
|
|
|
takes a right-hand operator of "... what?
Presumably one of the items you're trying to push into the stream is not a basic type, or is of a type that doesn't have << defined.
Try breaking your statement up a bit and you should find out which one is causing the problem:
s << "Stock information: ";
s << market.stockArray[i].getCompanyName();
s << " ";
etc...
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
This code cannot work. How can you have a loop, and return s in the first iteration ?
Anyhow, this code has some other issues. First of all, you need first to check the stream state. Second of all you need to create a sentry instance to perform prefix and postfix operations. Lastly, this code will not work with formating operators. The way I do it is to stream my data to an ostringstream, then pass it in one go to the ostream passed in. Here is an example
template<class chart,="" class="" traits="">
std::basic_ostream<chart, traits=""> &
operator << (std::basic_ostream<chart, traits=""> & os, const RECT & rc)
{
//Check stream state first
if (!os.good()) return os;
// Create sentry for prefix operations ( it's destructor will carry out postfix operations )
typename std::basic_ostream<chart, traits="">::sentry opfx(os);
if (opfx)
{
std::ostringstream str;
str << "left: " << rc.left;
str << " right : " << rc.right;
str << " top : " << rc.top;
str << " bottom : " << rc.bottom;
str << " width : " << rc.right - rc.left;
str << " height : " << rc.bottom - rc.top;
os << str.str().c_str();
}
return os;
}
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.
|
|
|
|
|
How do I intercept the command "net send" to remove the name of the user that did the sending in the remote pc's dialog box.
By this i mean somehow finding the HWND of that window and dynamically changing the text at the top of the dialog before
it is sent via a socket
-
|
|
|
|
|
How about this?
HWND hWnd;
HWND hStatic;
hWnd = ::FindWindow(NULL, "Messenger Service ");
if (hWnd)
{
hStatic = ::FindWindowEx(hWnd, NULL, "Static", NULL);
}
Cheers,
/Fredrik
Sonork ID: 100.11430:PhatBoy
|
|
|
|
|
Is it bad programming practice to use properties in your ATL components.
I mean which of the two is better :-
(1) Function(arg1, arg2, arg3)
(2)
arg1=100
arg2=100
arg3=200
Function()
The reason why I'd like to use properties is that I am planning to write some components for use from ASP. And the normal ASP/VB way is to use properties, I think so anyway.
Any ideas or suggestions on this are appreciated.
Thanks in advance.
Nish [ATL newbie]
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
|
|
|
|
|
I would say (and, to state again, this is only MY opinion)...
Only use a property if:
a) It is going to be persistent (stored with the object) or
b) It is used in more than one method in the object.
Use parameters if the values are only going to be used in that method, otherwise you're incurring the penalty of making COM calls for each parameter and then the method as well.
So, I think you can read that as suggesting parameters.
Also, in ASP you can quite happily use parameters, just like a Sub.
MyObject.MyMethod "Parameter 1", viParameter2, "Some Other Parameter"
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
Derek Waters wrote:
Use parameters if the values are only going to be used in that method, otherwise you're incurring the penalty of making COM calls for each parameter and then the method as well
Thanks a lot Derek. That was very useful.
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
|
|
|
|
|
With properties your component acquires state, so maynot scale well when deployed in MTS where Just in Time activation and ASAP deactivation help in improving throughput. Also if the components are deployed in remote machine or as out of proc components, look at the extra marshalling, network calls.
|
|
|
|
|
Thanks Ravish.
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
|
|
|
|
|
It is fine if you plan to use stateful programs.
If eventually, your app and the number of components grow
Using properties vs just methods or functions with parameters will slow down the application.
Using properties
1) More Overhead is created marshalling the asp - com calls
2) Limited threads in IIS are consumed longer by stateful components
3) There is an increase in RPC calls if dcom is used
Do you think you could solve my problem?
http://www.codeproject.com/script/comments/forums.asp?forumid=1647&select=114120&tid=114120#xx114120xx
Safearray and COM+
|
|
|
|
|
Thank you.
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
|
|
|
|
|
How can i change application icon dinamicaly?
|
|
|
|
|
If using MFC: CWnd::SetIcon
/moliate
|
|
|
|
|
Icon must be stay changed after close application (In Explorer - another icon).
|
|
|
|
|
You cant change your exe file's icon dynamically. You'd have to recompile it with a new icon. Unless you figure out some way to open the file and overwrite the icon with a new one.
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
|
|
|
|
|
To do so, you would need to update you main icon resource. If this is what you're after, you might want to check out:
BeginUpdateResource()
UpdateResource()
EndUpdateResource()
on MSDN. You'll need to use them to change your icon dynamically.
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
That is a lot harder. May be impossible. A possible solution might be to spawn a new process when the application is about to terminte. The process kills its parent, opens the parents .exe file, finds the icon and replaces it before terminating.
I really don't know if it will work. If the iconswapping is critical for your application you might give it a shot. As Derek pointed out you can use the resource function set.
/moliate
|
|
|
|
|
Icon must be stay changed after close application (In Explorer - another icon).
|
|
|
|
|
Hi,
I wanna ceate an SDI app with a CEditView or CHtmlView in it, and change between them per buttonclick.
The only thing I don't know is how to begin and then how to continue.
Would you help me, please?
Thank you.
Recaro
|
|
|
|
|
You should be able to do this by getting a pointer to the view you want to activate. Then gets its container child window and call MDIActivate() on it.
CView *pView = ... ;
CChildWnd *pChild = (CChildWnd*)pView->GetParent() ;
pChild->MDIActivate() ;
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
Please step to the rear of the car and make room for more victims. - John Simmons the Outlaw programmer, 1st Feb 2002, in the lounge
|
|
|
|
|
Hi.
I am studying MFC from Jeff Promise's book. I had problems compiling the first sample MFC program from Prosis because I need to set the project from "single-threaded" to "multi-threaded."
First, "multi-threaded" works, but the execute is huge, maybe five-folds from my biggest win32 console program with many more lines of code. The size of "multi-threaded" un debug mode was 1.5mb. There are less than 100 lines of code. I tried to set "multi-threaded" to "multi-threaded DLL," but then Visual C++ would not compile the source . It responded with a bunch of errors. Do I need to install anything before using the multi-threaded DLL mode?
How does MFC works as far as software release? Let say I give the MFC program to a friend. Will the friend be able to run it? Is MFC/C++ similar to Java and VB where the program comes require specific system DLL?
Lastly, Promise's book is exceptional because it touches everything about MFC. I found some MFC syntax that are not like C++ (or maybe it is just my inexperience). For example, some derived functions return "BOOL" and "TRUE." I know C++'s "bool" and "true." I replaced "TRUE" with "true," and that worked okay. However, Visual C++ came up with errors when I replaced "BOOL" with "bool." Are syntax like th ones above MFC specific and are required?
Kuphryn
|
|
|
|
|
The debug mode exe will be huge with static linking of MFC. But the release mode exe should be considerably smaller even with static linking.
If you link MFC dynamically, both the debug and release exes will be small with the release exe being really really small.
But if want tiny files use direct API or ATL
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
|
|
|
|
|
Yes, if you give your program to a friend they must have the correct DLLs resident on their machine. This is generally not a problem but older machines may have a MFC42.dll that is out of date. ComCtl32.dll is another one to watch out for but machines with recent OSs and service packs should be fine.
Regarding BOOL and bool, BOOL is a type defined as an int in windef.h. bool (lower case) is a built-in variable type having a size of 1 byte and this is from the standard. It is best to leave BOOL as BOOL because they are different types as of MSVC v5.0.
|
|
|
|
|
Okay. Thanks.
First, I would really want to multi-thread using DLL (dynamically). I will post the errors as soon as I get access to the source at home.
One more question about MFC syntax. I learn from Deitel & Deitel to using "0" instead of "NULL." However, MFC uses "NULL" consistantly. Should I use "NULL" as Promise implements it?
Kuphryn
|
|
|
|