Overload operator error ?

S

sd2004

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
 
M

Mike Wahler

sd2004 said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top