Hello again! here is one more code I am concerned with.This time I want to create a class Student (with constructors ets.). After all I want my ShowObj function to write the object to the file, but after I compile & run the programme I don't get my.txt output file, do you have any suggestions ? The code works
fine with cout instead of out_stream.
#include<iostream>
#include<fstream>
using namespace std;
class Student{
private:
int studentNo ;
string Address;
int age ;
public:
Student(int no, string Saddress, int Sage);
Student(int no, string Saddress);
Student(int no);
Student();
void SetAllData(int no, string Saddress, int Sage);
void SetNoandAddress(int no, string Saddress);
void SetNo(int no);
void SetAddress(string Saddress);
friend void ShowObj (Student obj);
};
Student::Student(int no, string Saddress, int Sage){
studentNo = no;
Address = Saddress ;
age = Sage ;
}
Student::Student(int no, string Saddress){
studentNo = no;
Address = Saddress;
age =0;
}
Student::Student(int no){
studentNo = no;
Address = "N/A";
age = 0;
}
void Student:: SetAllData(int no, string Saddress, int Sage){
studentNo = no;
Address = Saddress ;
age = Sage ;
}