Newbie C++ programmer again...

Furmanek, Greg Greg.Furmanek@hit.cendant.com
Fri, 18 Aug 2000 17:38:09 -0400


void* is a generic pointer notation.
It means you can stick whatever in that place.

-> -----Original Message-----
-> From: Robert Ambrose [mailto:rna@testpt.com]
-> Sent: Friday, August 18, 2000 2:28 PM
-> To: plug-devel@lists.PLUG.phoenix.az.us
-> Subject: Re: Newbie C++ programmer again...
-> 
-> 
-> 
-> I hate to keep doing this, I'm sure everyone is sick of 
-> this.  I promise
-> to shut up about it.  This is another minor change.  I admit 
-> I don't quite
-> understand why operator void* is preferable to operator bool, but the
-> standard C++ library uses operator void* so I figure I 
-> should at least
-> mention it here.
-> 
-> #include <iostream.h>
->  
-> class xyz
-> {
-> public:
-> 	xyx() {value = 0;}
-> 	~xyz() {};
-> 
-> 	int value;
-> 
-> 	xyz& set() {value = 1; cout << "set" << endl; return *this;};
-> 	xyz& clear() {value = 0; cout << "clear" << endl; 
-> return *this;};
-> 	operator void*() const {cout << "op void*" << endl; 
-> return value != 0 ? (void*)1 : (void*)0;};
-> 	operator !() const {cout << "op !" << endl; return value == 0;};
-> };
-> 
-> int main ()
-> {
-> 	xyz abc;
-> 
-> 	if(abc.set())
-> 		cout << "true" << endl;
-> 	if(!abc)
-> 		cout << "shouldn't happen" << endl;
-> 
-> 	if(!abc.clear())
-> 		cout << "true" << endl;
-> 	if(abc)
-> 		cout << "shouldn't happen" << endl;
-> }
-> 
-> rna
-> 
-> On Fri, 18 Aug 2000, Eric Samson wrote:
-> 
-> > Ok, I looked up some reference on the syntax you used, and 
-> I am not sure I 
-> > understand it..  From what I gathered, (cin >> foo) is 
-> actually a test to 
-> > see if the input is of the type declared and it returns a 
-> NULL if not and a 
-> > non-NULL is legal?
-> > 
-> > 
-> > ----Original Message Follows----
-> > From: Robert Ambrose <rna@testpt.com>
-> > Reply-To: plug-devel@lists.PLUG.phoenix.az.us
-> > To: plug-devel@lists.PLUG.phoenix.az.us
-> > Subject: Re: Newbie C++ programmer again...
-> > Date: Fri, 18 Aug 2000 09:33:02 -0700 (MST)
-> > 
-> > 
-> > The short answer is the state in the ios parent class has 
-> to be reset to
-> > good (cleared).  The long answer reauires to much typing 
-> ;-), and I've
-> > spent to much time on this already (anthough I did learn 
-> some usefull
-> > things).  If you really want to know, I'm always happy to 
-> talk it over a
-> > beer.
-> > 
-> > Here's a working program:
-> > 
-> > #include <iostream.h>
-> > #include <ctype.h>
-> > #include <limits.h>
-> > 
-> > int main ()
-> > {
-> > 	for(;;)
-> > 	{
-> > 		double dollars;	// Maybe I'll win the lotto
-> > 
-> > 		cout << "Enter dollars:";
-> > 
-> > 		if(cin >> dollars)
-> > 		{
-> > 			double pounds;
-> > 
-> > 			pounds = dollars / 1.49;
-> > 			cout << "is " << pounds << " pounds" << endl;
-> > 			break;
-> > 		}
-> > 		else
-> > 		{
-> > 			cin.clear();
-> > 			cin.ignore(INT_MAX, '\n');
-> > 			cout << "Not a valid dollar ammount, 
-> try again" << endl;
-> > 		}
-> > 	}
-> > 
-> > 	return 0;
-> > }
-> > 
-> > rna
-> > 
-> > On Fri, 18 Aug 2000, Eric Samson wrote:
-> > 
-> >  > Ok, I have about gone nuts trying to figure this out...
-> >  >
-> >  > This is my assignment that I am having trouble with..
-> >  >
-> >  > It's a simple currency converter, the user enters a 
-> float which indicates
-> >  > how many US dollars they want to convert to a specified 
-> currency, in my 
-> > case
-> >  > Deutchmarks...  That is the easy part, got it written 
-> no problem, simple
-> >  > math... An optional part of the assignment is to 
-> validate the user input 
-> > and
-> >  > be sure it is a numeric value (float), and not an alpha 
-> charater, symbol,
-> >  > etc...  If they enter something that will not work, 
-> they are supposed to 
-> > be
-> >  > prompted to try to enter the info again...  Preventing 
-> negative values is 
-> > no
-> >  > problem with the <while (someinput < 0)> loop, but if 
-> they enter an alpha
-> >  > value, it enters an infinite loop.  I went to borders 
-> last night and my
-> >  > roommate and I (mostly because he is tired of hearing 
-> me whine about it)
-> >  > looked in a bunch of books for a solution, and didn't 
-> have any luck.  My
-> >  > instructor was no help either, he wasn't sure how to do 
-> it (he is a VB
-> >  > programmer teaching C++, go figure)...  This seems like 
-> something that
-> >  > should be painfully simple...  Is this something too 
-> complex for a 
-> > beginning
-> >  > programmer?  I should think that it would be a basic 
-> part of programming,
-> >  > but I could be wrong...  I notice a few people on here 
-> saying they don't 
-> > use
-> >  > C++ much, so what is the language of choice for 
-> programming in Linux?
-> >  >
-> >  > Thanks again,
-> >  >
-> >  > Eric
-> >  > 
-> _____________________________________________________________
-> ___________
-> >  > Get Your Private, Free E-mail from MSN Hotmail at 
http://www.hotmail.com
>  >
>  >
>  > _______________________________________________
>  > Plug-devel mailing list  -  Plug-devel@lists.PLUG.phoenix.az.us
>  > http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-devel
>  >
> 
> 
> _______________________________________________
> Plug-devel mailing list  -  Plug-devel@lists.PLUG.phoenix.az.us
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-devel
> 
> ________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
> 
> 
> _______________________________________________
> Plug-devel mailing list  -  Plug-devel@lists.PLUG.phoenix.az.us
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-devel
> 


_______________________________________________
Plug-devel mailing list  -  Plug-devel@lists.PLUG.phoenix.az.us
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-devel