![]() |
|
#1
|
|||
|
|||
Operator>> ProblemHello all expert C++ programmer, i truly new to C++ environment.
I have a program where define the overload version of operator>> but give me some errors. I know that overload >> version only can ask input for variable inside the class only but i going to cin for local variable. Then the compiler give me some errors. I try to uncomment it but i doesn't compile successful. Below is my program. CPP / C++ / C Code:
CPP / C++ / C Code:
I really need to solve out this problem. Therefore, i hope you can guide me or give some advice. Thanks for your help. Your help is greatly appreciated by me and others. |
|
#2
|
|||
|
|||
Re: Operator>> ProblemWhat's the error? My theory is it (if only one) says something about not knowing what an istream is. Take a look and see where you tell your class queue where to find the istream definition in the std namespace.
|
|
#3
|
|||
|
|||
Re: Operator>> ProblemQuote:
I didn't spend anytime looking at your code, but maybe this will help? It shows both streaming operator implementations, but for a rather trivial class implementation. www.gidforums.com It may be helpful. :davis: |
|
#4
|
|||
|
|||
Re: Operator>> ProblemI have check the program but the program it does the same thing as me. I mean the operator>> and its definition.
The only difference is i use operator>> to cin local variable. I don't know this will give me errors like this. Thanks for your help. |
|
#5
|
|||
|
|||
Re: Operator>> ProblemDid you try
CPP / C++ / C Code:
I suspect you are not getting the correct istream library loaded. Last edited by LuciWiz : 17-Sep-2007 at 13:42.
|
|
#6
|
|||
|
|||
Re: Operator>> ProblemWhat a blind mistake made by me ?
Thanks for your help. |
|
#7
|
|||
|
|||
Re: Operator>> ProblemI get another error message during execute.
The error message is unresolved external and i know it is related to the definition of a function. You call the function but don't have the implementation. I really don't know which one i left out. Error Message: Quote:
Sorry for my stupidity. |
|
#8
|
|||
|
|||
Re: Operator>> ProblemUsing your class code, what should happen when we do the following:
CPP / C++ / C Code:
q should be displayed but by what method? What are the exact steps as it enters the operator<< definition you've created? I'll give you a hint: The problem lies with this line of code: CPP / C++ / C Code:
|
|
#9
|
|||
|
|||
Re: Operator>> Problemq is display with this the operator<<. I not really sure what is the step the called get into the function(method) definition.
I guess is something like this: cout.operator<<(q); After the hind you giving to me, i think i some related to loop right where i inside the queue class, i have create a certain size of queue by i never display it by loop. I really don't know how to solve after this. Thanks for your hind and help. |
|
#10
|
|||
|
|||
Re: Operator>> Problemtry removing the const keyword from queue in your operator<< overload.
There are other potential problems in your code. Did you really want a specialised add method just for integers when your queue is of type T?? Peter in order to get better feedback, in general I would recommend you first implement a simple queue with display before making your class templated. |
Recent GIDBlog
Meeting the populace by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Buffer problem with CD-RWriter | KieranC | Computer Software Forum - Windows | 2 | 07-Jan-2006 01:45 |
| Graphic problem in Unreal Tournament 2004 | zerox | Computer Software Forum - Games | 10 | 09-Oct-2005 12:31 |
| Runtime Problem involving "printf" in C Program | supamakia | C Programming Language | 2 | 09-Oct-2005 10:09 |
| a significant problem after installing Xp | mohammad | Computer Software Forum - Windows | 10 | 09-Aug-2005 07:03 |
| Another FX 5600 problem (but with details that might shed light on this) | BobDaDuck | Computer Hardware Forum | 2 | 16-Apr-2004 07:53 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The