Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 02-18-2004, 04:38 PM   #1 (permalink)
MadMAxJr
Registered User
 
Join Date: Feb 2004
Location: Central Oklahoma
Posts: 4
MadMAxJr is on a distinguished road
Send a message via ICQ to MadMAxJr
Overloading Operators.

I'm getting some unusual errors trying to work this block of code. I have to overload the >> operator of cin so that when I give it a class, it will kick out all 3 of the private class contents.

istream &operator>>( istream &input, Time &thingy )
{
input >> thingy.setHour;
input.ignore();
input >> thingy.setMin;
input.ignore();
input >> thingy.setSec;

return input;

the 'set' calls are functions that assign the given values to the private variables of the class. I get this error

: error C2679: binary '>>' : no operator defined which takes a right-hand operand of type '' (or there is no acceptable conversion)

(edit: this error occurs on the lines where the set functions are called)

Help? I just need to get an understanding of what this error means, really.
MadMAxJr is offline   Reply With Quote
Old 02-18-2004, 05:28 PM   #2 (permalink)
MadMAxJr
Registered User
 
Join Date: Feb 2004
Location: Central Oklahoma
Posts: 4
MadMAxJr is on a distinguished road
Send a message via ICQ to MadMAxJr
Nevermind, fixed it. Silly me, calling a function without passing any parameters whatsoever to it. NEW problem!

This warning occurs 3 times in this line of code on the output line.

warning C4761: integral size mismatch in argument; conversion supplied

Code:
stream &operator<<( ostream &output, const Time &thingy )
{

	output << setw(2) << setfill('0')<< thingy.getHour <<":"<< thingy.getMin<<":"<< thingy.getSec;
	return output;  // Should be HR:MN:SC output
}
Thingy is a time class that holds hour, minute, seconds. The goal of this line is to output in a format with leading zeroes if a digit is less than ten.
MadMAxJr is offline   Reply With Quote
Old 02-18-2004, 06:11 PM   #3 (permalink)
sdeming
Code Monkey
 
Join Date: Jul 2002
Location: Michigan
Posts: 85
sdeming is on a distinguished road
You have to call functions with (), even if they have no parameters. Change your thingy.getHour, thing.getMin, thingy.getSec to thingy.getHour(), thingy.getMin(), and thingy.getSec() and you should be good.
__________________
Scott
B4 09 BA 09 01 CD 21 CD 20 53 63 6F 74 74 24
sdeming is offline   Reply With Quote
Old 02-18-2004, 06:22 PM   #4 (permalink)
MadMAxJr
Registered User
 
Join Date: Feb 2004
Location: Central Oklahoma
Posts: 4
MadMAxJr is on a distinguished road
Send a message via ICQ to MadMAxJr
Your assisstance is greatly appreciated, in addtion to the quick reply. Thank you.
MadMAxJr is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
operate overloading member function in C# sureshkumar_kc MS Technologies ( ASP, VB, C#, .NET ) 2 10-15-2004 03:36 AM
Operator= overloading SuperFerrell Standard C, C++ 3 02-04-2003 03:43 PM
c++ overloading sde Standard C, C++ 0 06-20-2002 08:38 PM


All times are GMT -8. The time now is 01:04 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting