473,402 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Overload operator error ?

Could someone please help ?
I am getting compiling error but do not understand why ?
below is snipset of code:

istream& operator>>(istream& is, test_ins& s){
is >>s.pass>>s.put>>s.type; //line 22
is >>s.test_one>>s.test_two>>s.test_three; /line 23
is >>s.test_four >>s.test_five>>s.test_six; //line 24
is>>s.force>>s.weight;
is>>s.label>>s.start>>s.stop;
is>>s.min>>s.max>>s.clamp;
is>>s.time>>s.desc;
return is;
}

test.cpp:22: error: syntax error before `.' token
test.cpp:23: error: syntax error before `.' token
test.cpp:24: error: syntax error before `.' token
test.cpp:25: error: syntax error before `.' token
test.cpp:26: error: syntax error before `.' token
test.cpp:27: error: syntax error before `.' token
test.cpp:28: error: syntax error before `.' token

Jan 19 '06 #1
1 1786

"sd2004" <tv****@hotmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Could someone please help ?
I am getting compiling error but do not understand why ?
below is snipset of code:

istream& operator>>(istream& is, test_ins& s){
is >>s.pass>>s.put>>s.type; //line 22
is >>s.test_one>>s.test_two>>s.test_three; /line 23
is >>s.test_four >>s.test_five>>s.test_six; //line 24
is>>s.force>>s.weight;
is>>s.label>>s.start>>s.stop;
is>>s.min>>s.max>>s.clamp;
is>>s.time>>s.desc;
return is;
}

test.cpp:22: error: syntax error before `.' token
test.cpp:23: error: syntax error before `.' token
test.cpp:24: error: syntax error before `.' token
test.cpp:25: error: syntax error before `.' token
test.cpp:26: error: syntax error before `.' token
test.cpp:27: error: syntax error before `.' token
test.cpp:28: error: syntax error before `.' token


It appears that the compiler doesn't know what 's' is.

Have you given the compiler all the information it
needs? E.g. did you #include <istream> as well as
make the definition of type 'test_ins' visible to
this code? Is it valid to use '.' operator with
object of type 'test_ins'? (i.e. is it a struct or
class type?)

-Mike
Jan 19 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Piotre Ugrumov | last post by:
I have tried to implement the overload of these 2 operators. ostream & operator<<(ostream &out, Person &p){ out<<p.getName()<<" "<<p.getSurname()<<", "<<p.getDateOfBirth()<<endl; return out; }...
1
by: Piotre Ugrumov | last post by:
I'm following your help. I have written the overload of the operator <<. This overload work! :-) But I have some problem with the overload of the operator >>. I have written the overload of this...
3
by: Piotre Ugrumov | last post by:
I have done the overload on the operator >> and << in the class Attore. These 2 overload work correctly. I have done the overload of the same overload in the class Film. The class film ha inside...
5
by: Gianni Mariani | last post by:
Can anyone enligten me why I get the "ambiguous overload" error from the code below: friendop.cpp: In function `int main()': friendop.cpp:36: ambiguous overload for `std::basic_ostream<char,...
7
by: Sean | last post by:
Can someone help me see why the following "operator=" overloading doesn't work under g++? and the error message is copied here. I see no reason the compiler complain this. Thanks, $ g++...
6
by: Harry J. Smith | last post by:
How do you overload the = operator? public static MultiUI operator = (MultiUI left, MultiUI right) { return right; }
9
by: Tony | last post by:
I have an operator== overload that compares two items and returns a new class as the result of the comparison (instead of the normal bool) I then get an ambiguous operater compile error when I...
5
by: phiefer3 | last post by:
I'm currently a student, but this problem isn't directly related to what I have to do on an assignment. It's just a problem I've had with some supporting features. First of all, I'm using MSVS...
11
by: onkar | last post by:
#include<iostream> using namespace std; class Integer{ int i; public: Integer(int ii):i(ii){} const Integer operator+(const Integer& rv){ cout<<"1-operator+"<<endl; return Integer(i+rv.i); }
2
by: xtrigger303 | last post by:
Hi to all, I was reading Mr. Alexandrescu's mojo article and I've a hard time understanding the following. Let's suppose I have: //code struct A {}; struct B : A {};
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.