Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
309 views
in Technique[技术] by (71.8m points)

c++ - error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>'

I am unable to understand this error.This error is not in the class that i am debugging . (Is it ?) The error is :

c:program filesmicrosoft visual studio 10.0vcincludefstream(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 filesmicrosoft visual studio 10.0vcincludeios(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 ==========

What could be the reasons i am getting this error ? The code is too lengthy to post. The compiler that i am using is Microsoft visual c++ 2010 express

EDIT:

    void HostelManager::guestMonitor() {
        system("cls");

        cout << "Name of the guest : "; // cin guest
        cin.ignore();
        getline( cin , guestName );

        cout << "
Whom to meet : ";   // to whom the guest wants to meet
        cin.ignore();
        getline( cin , fullName ); 

        string pathGND = "d:/HostelManager/studentDetails/groundFloor/" + fullName + ".txt";
        string pathFST = "d:/HostelManager/studentDetails/firstFloor/" + fullName + ".txt";
        string pathSND = "d:/HostelManager/studentDetails/firstFloor/" + fullName + ".txt";
        ifstream checkStudentGND( pathGND );
        ifstream checkStudentFST( pathFST );
        ifstream checkStudentSND( pathSND );
        string x = "Floor";

        if( checkStudentGND ) {
            ifstream readRoom( pathGND );
            readRoom >> fullName >> fatherName >> permanentAddress >> postalAddress >> x >> roomNumberToBeAlloted_GND;
            int hisRoomNumber = roomNumberToBeAlloted_GND;
            readRoom.close();
            storeGuestData( hisRoomNumber , fullName );  // call to store guest data
        } else if( checkStudentFST ) {
            ifstream readRoom( checkStudentFST );
            readRoom >> fullName >> fatherName >> permanentAddress >> postalAddress >> x >> roomNumberToBeAlloted_FST;
            int hisRoomNumber = roomNumberToBeAlloted_FST;
            storeGuestData( hisRoomNumber , fullName );  // call to store guest data
        } else if( checkStudentSND ) {
            ifstream readRoom( checkStudentSND );
            readRoom >> fullName >> fatherName >> permanentAddress >> postalAddress >> x >> roomNumberToBeAlloted_SND;
            int hisRoomNumber = roomNumberToBeAlloted_SND;
            storeGuestData( hisRoomNumber , fullName );  // call to store guest data
        } else {
            string sorryMSG = "Sorry ! The student is not in this hostel"                  cout << sorryMSG << endl ;
        }
   }

The called function:

    void HostelManager::storeGuestData( int hisRoomNumber , string hisName ) {
        cout << "
Visitor's Address : ";  // cin visitor address
        string visitorAddress;
        getline( cin , visitorAddress );

        cout << "
Relation with the student : ";   // cin relation with student
        string relation;
        getline( cin , relation );

        cout << "
Enter Month";    // cin enter month
        short month;
        cin >> month;

        cout << "
Enter Date";    // cin enter date
        short date;
        cin >> date;

        cout << "
You can meet " << hisName << " in room number " << hisRoomNumber << endl ;

        string visitorPath = "d:/HostelManager/GuestMonitor/" + fullName + ".txt" ;
        ofstream guestEntry( visitorPath );
        guestEntry << "Name of Visitor : " << guestName << endl ;
        guestEntry << "To meet : " << fullName << endl ;
        guestEntry << "Address of visitor : " << visitorAddress << endl ;
        guestEntry << "Relation with the student : " << relation << endl ;
        guestEntry << "Month : " << month << endl ;
        guestEntry << "Date : " << date << endl ; 
        guestEntry.close();
        cout << "



Data successfully inserted";
    }

Data Members:

    private:
        string fullName;
        string fatherName;
        string permanentAddress;
        string postalAddress;
        int mobileNumbers[2][10];
        double percentageMarks;
        int roomNumber;
        int roomNumberToBeAlloted_GND ;
        int roomNumberToBeAlloted_FST ;
        int roomNumberToBeAlloted_SND ;
        string preferredFloor;
        string guestName;
        string studentFined;
        string complaintAgainst;
        string receiverOfEmail;
        string senderOfEmail;
        string subject;

    public:
        void guestMonitor();
        void storeGuestData( int hisRoomNumber , string hisName );
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You are trying to copy a stream, which is not possible.

To help you avoid that, one of the base classes has a private copy constructor.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.8k users

...