Click here to Skip to main content
13,704,913 members

C / C++ / MFC

 
AnswerRe: why ( const char *ptr = string literal ) works but ( const string *ptr = string literal ) doesn't ? Pin
leon de boer3-Apr-18 13:48
memberleon de boer3-Apr-18 13:48 
QuestionHelp compiling OpenCV Pin
_Flaviu2-Apr-18 23:25
member_Flaviu2-Apr-18 23:25 
AnswerRe: Help compiling OpenCV Pin
Victor Nijegorodov3-Apr-18 2:04
memberVictor Nijegorodov3-Apr-18 2:04 
GeneralRe: Help compiling OpenCV Pin
_Flaviu3-Apr-18 2:08
member_Flaviu3-Apr-18 2:08 
GeneralRe: Help compiling OpenCV Pin
_Flaviu3-Apr-18 2:08
member_Flaviu3-Apr-18 2:08 
GeneralRe: Help compiling OpenCV Pin
Victor Nijegorodov3-Apr-18 4:08
memberVictor Nijegorodov3-Apr-18 4:08 
AnswerRe: Help compiling OpenCV Pin
Jochen Arndt3-Apr-18 23:02
mvpJochen Arndt3-Apr-18 23:02 
QuestionCreating a Simple Employee Database using inheritance in c++. Pin
Tarun Jha2-Apr-18 0:53
memberTarun Jha2-Apr-18 0:53 
the following question is to be done using the concept of hierarchical inheritance
staff - > teacher, officer, typist
typist -> regular, casual

my solution is giving an Runtime error
below is my code :
//To maintain a database of an educational institutional using hierarchical relationships. (application of virtual classes)
#include <iostream>
#include <string>
using namespace std;

//------------------------------------------------------------------------------------------------------------------------------------------------------------------
class staff {
    string code, name;
public:
    staff() : code(0000), name("Unknown") {}

    virtual void getdata(void){
        cout << "Enter employee name : " << endl;
        getline(cin, name);
        cout << "Enter employee code : " << endl;
        cin >> code ;
    }
    virtual void putdata(void){
        cout << "Employee name : " << name << endl
             << "Employee code : " << code << endl ;
    }
};

class teacher : public staff {
    string subject;
    int publication;
public:
    teacher() : subject("Empty"), publication(0000) {}
    void getdata(void);
    void putdata(void);
};

void teacher::getdata(){
    staff::getdata();
    cout << "Enter subject : " << endl ;
    cin >> subject;
    cout << "Enter total number of publications : " << endl ;
    cin >> publication ;
}

void teacher::putdata(){
    staff::putdata();
    cout << "Subject : " << subject << endl
         << "publications : " << publication << endl;
}


class officer : public staff {
    int grade;
    string posting ;
public:
    officer() : grade(0), posting("Unavailable") {}
    void getdata(void);
    void putdata(void);
};

void officer::getdata(){
    staff::getdata();
    cout << "Enter the grade : " << endl;
    cin >> grade;
    cout << "Enter the posting : " <<endl;
    getline(cin, posting);
}

void officer::putdata(){
    staff::putdata();
    cout << "Officer Grade : " << grade << endl
         << "Officer Posting : " << posting << endl ;
}

class typist : public staff {
    int speed;
    float experience;
public:
    typist() : speed(0), experience(0) {}

    virtual void getdata(void);
    virtual void putdata(void);
};

void typist::getdata(){
    staff::getdata();
    cout << "Enter typing speed :- (word/second) : " << endl;
    cin >> speed;
    cout << "Enter experience (int years) : " << endl;
    cin >> experience ;
}

void typist::putdata(){
    staff::putdata();
    cout << "Typing speed ( words/second ) : " << speed << endl
         << "Experience ( in years ) : " << experience << endl ;
}

//--------------------------------------------------------------------------------------------------------------------------------------------------------

class casual : public typist {
    double daily_wages;
public:
    casual() : daily_wages(100) {}

    void getdata(void);
    void putdata(void);
};

void casual::getdata(){
    typist::staff::getdata();
    cout << "Enter the daily wage : " << endl ;
    cin >> daily_wages;
}

void casual::putdata(){
    typist::putdata();
    cout << "Daily waged : " << daily_wages << endl ;
}

class regular : public typist {
    double monthly_wage;
public:
    regular() : monthly_wage(3000) {}

    void getdata(void);
    void putdata(void);
};

void regular::getdata(){
    typist::getdata();
    cout << "Enter Monthly wage : " << endl ;
    cin >> monthly_wage;
}

void regular::putdata(){
    typist::putdata();
    cout << "Monthly wage : " << monthly_wage << endl;
}

//=====================================================================================================================================================================

int main(){
    regular r1;
    r1.getdata();
    r1.putdata();

    return 0;
}


i am not able to understand the following error:

Quote:
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_M_construct null not valid

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.


Thank you
SuggestionRe: Creating a Simple Employee Database using inheritance in c++. Pin
Richard MacCutchan2-Apr-18 0:57
protectorRichard MacCutchan2-Apr-18 0:57 
GeneralRe: Creating a Simple Employee Database using inheritance in c++. Pin
Tarun Jha2-Apr-18 0:59
memberTarun Jha2-Apr-18 0:59 
GeneralRe: Creating a Simple Employee Database using inheritance in c++. Pin
Richard MacCutchan2-Apr-18 1:10
protectorRichard MacCutchan2-Apr-18 1:10 
GeneralRe: Creating a Simple Employee Database using inheritance in c++. Pin
Tarun Jha2-Apr-18 2:32
memberTarun Jha2-Apr-18 2:32 
AnswerRe: Creating a Simple Employee Database using inheritance in c++. Pin
Richard MacCutchan2-Apr-18 1:19
protectorRichard MacCutchan2-Apr-18 1:19 
GeneralRe: Creating a Simple Employee Database using inheritance in c++. Pin
Tarun Jha2-Apr-18 1:19
memberTarun Jha2-Apr-18 1:19 
GeneralRe: Creating a Simple Employee Database using inheritance in c++. Pin
Richard MacCutchan2-Apr-18 1:26
protectorRichard MacCutchan2-Apr-18 1:26 
QuestionIs it possible to link a DLL in another DLL and call its functions? Pin
manoharbalu2-Apr-18 0:29
membermanoharbalu2-Apr-18 0:29 
AnswerRe: Is it possible to link a DLL in another DLL and call its functions? Pin
Richard MacCutchan2-Apr-18 0:59
protectorRichard MacCutchan2-Apr-18 0:59 
QuestionMFC DDX_Radio causes debug assertion failure when DoDataExchange is called Pin
janaswamy uday30-Mar-18 2:34
memberjanaswamy uday30-Mar-18 2:34 
AnswerRe: MFC DDX_Radio causes debug assertion failure when DoDataExchange is called Pin
Victor Nijegorodov30-Mar-18 3:34
memberVictor Nijegorodov30-Mar-18 3:34 
GeneralRe: MFC DDX_Radio causes debug assertion failure when DoDataExchange is called Pin
janaswamy uday30-Mar-18 4:37
memberjanaswamy uday30-Mar-18 4:37 
GeneralRe: MFC DDX_Radio causes debug assertion failure when DoDataExchange is called Pin
Victor Nijegorodov30-Mar-18 6:29
memberVictor Nijegorodov30-Mar-18 6:29 
GeneralRe: MFC DDX_Radio causes debug assertion failure when DoDataExchange is called Pin
janaswamy uday30-Mar-18 7:42
memberjanaswamy uday30-Mar-18 7:42 
GeneralRe: MFC DDX_Radio causes debug assertion failure when DoDataExchange is called Pin
Richard Andrew x6430-Mar-18 15:11
professionalRichard Andrew x6430-Mar-18 15:11 
SuggestionRe: MFC DDX_Radio causes debug assertion failure when DoDataExchange is called Pin
Jochen Arndt30-Mar-18 22:17
mvpJochen Arndt30-Mar-18 22:17 
GeneralRe: MFC DDX_Radio causes debug assertion failure when DoDataExchange is called Pin
janaswamy uday1-Apr-18 21:05
memberjanaswamy uday1-Apr-18 21:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Cookies | Terms of Service
Web01-2016 | 2.8.180920.1 | Last Updated 22 Sep 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid