
-----------------------------------
deltatux
Mon Feb 23, 2009 3:44 pm

g++ compilation error
-----------------------------------
Hey guys,

I'm quite confused here. My program works perfectly when compiled on Visual Studio 2008 but it doesn't compile on G++.

I don't even understand the error. I know that the ifstream is part of the C++ standard library so it makes even less sense:


isbnprefix.cpp: In function 'int registered(FILE*, int)':
isbnprefix.cpp:32: error: no matching function for call to 'std::basic_ifstream::basic_ifstream(FILE*&)'
/usr/include/c++/4.1.2/fstream:442: note: candidates are: std::basic_ifstream::basic_ifstream(const char*, std::_Ios_Openmode) 

My isbnprefix.cpp as follows:

/*  isbnprefix.cpp
 *  Assignment 1's ISBN prefix program file.
 *  Copyright (C) 2009 Adrien Kwok.
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License Version 3
 *  as published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see .
 *
 */
#include "stdheader.h"
#include "prefix.h"

void seekStart(FILE* fp) {
	fseek(fp, 0, SEEK_SET);
}

FILE* open(const char* filename){
	FILE* fp = new FILE;
	fp = fopen (filename, "r");
	return fp;
}
int registered(FILE* fp, int area){
	seekStart(fp);
	ifstream in(fp);
	while (!in.eof()) {
		int area0, minPublisher, maxPublisher;
		in >> area0 >> minPublisher >> maxPublisher;
		if (area0 == area) return true;
	}
	return false;
}
int minNoDigits(FILE* fp, int area){
	seekStart(fp);
	ifstream in(fp);
	while (!in.eof()) {
		// read one line
		int area0, minPublisher, maxPublisher;
		in >> area0 >> minPublisher >> maxPublisher;
		cout 