
-----------------------------------
deltatux
Tue Feb 03, 2009 12:50 am

VS2008: Error C2679 help?
-----------------------------------
Hey guys,

I'm trying to open a file, however, I'm running into problems:

TDirectory.cpp

#include 
using namespace std;
#include 
#include "TDirectory.h"
bool Listing::loadFileData(FILE* fp){
	fseek(fp, 0, SEEK_SET);
	ifstream in(fp);
	while (in) {
		in >> givenName >> surname >> address >> telephone;
	}
}


TDirectory.h

struct Listing {
	char fname[16], lname[16], addr[16], phnum[16];

public:
	bool loadFileData(FILE *fp);
    const char* givenName() const;
    const char* surname() const;
    const char* address() const;
    const char* telephone() const;
};

struct Directory {
	FILE *fp;
	int records;
	struct Listing *listings;

public:
	bool loadFileData(const char* filename);
	void display() const;
	void close();
};


Error:

error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'overloaded-function' (or there is no acceptable conversion)


If I can't get this fixed, I might be forced to mix C with C++ and it'll go ugly...

Many thanks,
deltatux

-----------------------------------
DemonWasp
Tue Feb 03, 2009 9:17 am

RE:VS2008: Error C2679 help?
-----------------------------------
Your input statement:
in >> givenName >> surname >> address >> telephone; 

is trying to read strings into your getter functions. That's probably not what you meant.

-----------------------------------
md
Tue Feb 03, 2009 12:07 pm

RE:VS2008: Error C2679 help?
-----------------------------------
Furthermore, character strings are a C construct. When using C++ you should use std::string wherever possible.

-----------------------------------
deltatux
Tue Feb 03, 2009 1:48 pm

RE:VS2008: Error C2679 help?
-----------------------------------
So should I just read them directly into chars in the struct?

it worked on my other software but am having a tough time with this one =s...

deltatux

-----------------------------------
DemonWasp
Tue Feb 03, 2009 1:50 pm

RE:VS2008: Error C2679 help?
-----------------------------------
No, just use the >> operator and change the types of your string variables to be std::string .

-----------------------------------
deltatux
Tue Feb 03, 2009 4:04 pm

RE:VS2008: Error C2679 help?
-----------------------------------
How do I do that?

deltatux

-----------------------------------
wtd
Tue Feb 03, 2009 4:55 pm

RE:VS2008: Error C2679 help?
-----------------------------------
While you're at it, mixing C file handling and C++ iostreams is a good way to give yourself a headache.

-----------------------------------
wtd
Tue Feb 03, 2009 5:11 pm

RE:VS2008: Error C2679 help?
-----------------------------------
Think about what the error is telling you:

error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'overloaded-function' (or there is no acceptable conversion) 

For the binary operator >> it's getting a right-hand operator of type overloaded-function.

What does this mean?

-----------------------------------
deltatux
Tue Feb 03, 2009 5:27 pm

Re: RE:VS2008: Error C2679 help?
-----------------------------------
While you're at it, mixing C file handling and C++ iostreams is a good way to give yourself a headache.

Unfortunately, at my college, they came up with this brilliant idea by mixing C with C++ since we did C last semester, so they thought that by mixing C in C++ it'll make the transition easier =S... I think they shouldn't have done that.

It's very confusing.

and I don't understand the error at all >.