File inputs without the stream state?

Is there a standard function in c++ that can perform file inputs like ifstream does but without invoking any of the stream state libraries. Similar to how printf performs text outputs without using ostream objects like cout.
there is a way with pointers(how they did it in the library) but it is complicated and why do that when u can just file.open("hi.txt"); ?
I'm wondering because I need to open a file within a class member function with an ifstream object as its parameter, and I'm getting all sorts of weird errors that I don't understand. So, I'm wondering if there is another way to do it without invoking a library file.
How about posting the errors you are getting. Sounds like an operator overload issue. Blind guess without any code...
Alright here's my code. Just so that you know, this is a homework assignment.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#include <iostream>
#include <fstream>
#include <cmath>
#include <iomanip>

using namespace std;

class Student_Grade
{
	
	char SFN[12];     // Student First Name
	double MTE;       // Mid-Term Exam Grade
	double FE;        // Final Exam Grade
	double QAG;       // Average Quiz Grade
	double FG;        // Final Grade

	public:
		void getStudentData(ifstream Name, ifstream Midterm, ifstream Final, ifstream Quiz);
		double calculateGrade(void);
		void showGrade(void);
};

#define totalStudents 46                                   // The total number of students in the class

void equals(int size);                                     // Function prototype

int main(void)
{
	int i;
	Student_Grade Grades[totalStudents];
	ifstream name("Student_data/FristName.txt");
	ifstream midterm("Student_data/MidtermExam.txt");
	ifstream final("Student_data/FinalExam.txt");
	ifstream quiz("Student_data/QuizAve.txt");

	for (i = 0; i < totalStudents; i++)
	{
		Grades[i].getStudentData(name, midterm, final, quiz);
	}
	name.close();
	midterm.close();
	final.close();
	quiz.close();

	cout << "Stage 1: Uploading all data from Data File into 46 objects completed\n";
	system("pause");

	for (i = 0; i < totalStudents; i++)
	{
		Grades[i].calculateGrade();
	}

	cout << "\nStage 2: Final Grade calculation Done\n";
	system("pause");

	cout << "\nStage 3: Students and their final Letter Grade ready\n";
	system("pause");

	cout << endl << setw(12) << "First Name" << setw(14) << "Final Grade" << endl;
	for (i = 0; i < totalStudents; i++)
	{
		Grades[i].showGrade();
		cout << endl;
	}

	system("pause");
	return 0;
}

void equals(int size)
{
	for (int eq = 1; eq < size; eq++)
		cout << "=";
	cout << endl;
}

void Student_Grade::getStudentData(ifstream Name, ifstream Midterm, ifstream Final, ifstream Quiz)
{
	
	Name >> SFN;
	
	Midterm >> MTE;
	
	Final >> FE;
	
	Quiz >> QAG;
}
	
double Student_Grade::calculateGrade(void)
{
	FG = (0.35 * MTE) + (0.35 * FE) + (0.3 * QAG);
	return FG;
}

void Student_Grade::showGrade(void)
{
	cout << setw(11) << SFN;
	if (FG >= 90.0 && FG <= 100.0)
	{
		cout << setw(12) << "A";
		if (FG >= 90.0 && FG <= 93.3)
			cout << "-";
		else if (FG > 93.3 && FG < 96.6)
			cout << " ";
		else if (FG >= 96.6 && FG <= 100.0)
			cout << "+";
	}
	else if (FG >= 80.0 && FG <= 89.9)
	{
		cout << setw(12) << "B";
		if (FG >= 80.0 && FG <= 83.3)
			cout << "-";
		else if (FG > 83.3 && FG < 86.6)
			cout << " ";
		else if (FG >= 86.6 && FG <= 89.9)
			cout << "+";
	}
	else if (FG >= 70.0 && FG <= 79.9)
	{
		cout << setw(12) << "C";
		if (FG >= 70.0 && FG <= 73.3)
			cout << "-";
		else if (FG > 73.3 && FG < 76.6)
			cout << " ";
		else if (FG >= 76.6 && FG <= 79.9)
			cout << "+";
	}
	else if (FG >= 0.0 && FG <= 69.9)
		cout << setw(12) << "FAIL";
	else
		cout << setw(12) << "ERROR";
}
And these are the errors that I'm getting...

1>------ Build started: Project: Assignment 4, Configuration: Debug Win32 ------
1>  Roberts_A4.cpp
1>c:\program files\microsoft visual studio 10.0\vc\include\fstream(890): error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ios(176) : see declaration of 'std::basic_ios<_Elem,_Traits>::basic_ios'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>
1>          ]
1>          This diagnostic occurred in the compiler generated function 'std::basic_ifstream<_Elem,_Traits>::basic_ifstream(const std::basic_ifstream<_Elem,_Traits> &)'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>
1>          ]
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
stream objects can't be copied so you have to pass std::ifstream by reference to the function.
How do I do that?
By changing ifstream to ifstream& in the parameter list.
IT WORKS!! IT WORKS!! Thanks so much for your help!! THANK YOU!! THANK YOU!
Topic archived. No new replies allowed.