Click here to Skip to main content
15,905,682 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How can I initialize an array of structs where the array size is set at compile time? Pin
Richard MacCutchan5-Apr-18 23:26
mveRichard MacCutchan5-Apr-18 23:26 
GeneralRe: How can I initialize an array of structs where the array size is set at compile time? Pin
arnold_w6-Apr-18 0:31
arnold_w6-Apr-18 0:31 
GeneralRe: How can I initialize an array of structs where the array size is set at compile time? Pin
Jochen Arndt6-Apr-18 0:55
professionalJochen Arndt6-Apr-18 0:55 
GeneralRe: How can I initialize an array of structs where the array size is set at compile time? Pin
arnold_w6-Apr-18 1:30
arnold_w6-Apr-18 1:30 
AnswerRe: How can I initialize an array of structs where the array size is set at compile time? Pin
Jochen Arndt5-Apr-18 23:36
professionalJochen Arndt5-Apr-18 23:36 
GeneralRe: How can I initialize an array of structs where the array size is set at compile time? Pin
arnold_w6-Apr-18 0:32
arnold_w6-Apr-18 0:32 
GeneralRe: How can I initialize an array of structs where the array size is set at compile time? Pin
Jochen Arndt6-Apr-18 1:13
professionalJochen Arndt6-Apr-18 1:13 
AnswerRe: How can I initialize an array of structs where the array size is set at compile time? Pin
Joe Woodbury6-Apr-18 6:06
professionalJoe Woodbury6-Apr-18 6:06 
Questionwhy ( const char *ptr = string literal ) works but ( const string *ptr = string literal ) doesn't ? Pin
Tarun Jha3-Apr-18 7:53
Tarun Jha3-Apr-18 7:53 
AnswerRe: why ( const char *ptr = string literal ) works but ( const string *ptr = string literal ) doesn't ? Pin
Victor Nijegorodov3-Apr-18 9:03
Victor Nijegorodov3-Apr-18 9:03 
AnswerRe: why ( const char *ptr = string literal ) works but ( const string *ptr = string literal ) doesn't ? Pin
David Crow3-Apr-18 10:41
David Crow3-Apr-18 10:41 
AnswerRe: why ( const char *ptr = string literal ) works but ( const string *ptr = string literal ) doesn't ? Pin
leon de boer3-Apr-18 13:48
leon de boer3-Apr-18 13:48 
QuestionHelp compiling OpenCV Pin
_Flaviu2-Apr-18 23:25
_Flaviu2-Apr-18 23:25 
AnswerRe: Help compiling OpenCV Pin
Victor Nijegorodov3-Apr-18 2:04
Victor Nijegorodov3-Apr-18 2:04 
GeneralRe: Help compiling OpenCV Pin
_Flaviu3-Apr-18 2:08
_Flaviu3-Apr-18 2:08 
GeneralRe: Help compiling OpenCV Pin
_Flaviu3-Apr-18 2:08
_Flaviu3-Apr-18 2:08 
GeneralRe: Help compiling OpenCV Pin
Victor Nijegorodov3-Apr-18 4:08
Victor Nijegorodov3-Apr-18 4:08 
AnswerRe: Help compiling OpenCV Pin
Jochen Arndt3-Apr-18 23:02
professionalJochen Arndt3-Apr-18 23:02 
QuestionCreating a Simple Employee Database using inheritance in c++. Pin
Tarun Jha2-Apr-18 0:53
Tarun 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
mveRichard MacCutchan2-Apr-18 0:57 
GeneralRe: Creating a Simple Employee Database using inheritance in c++. Pin
Tarun Jha2-Apr-18 0:59
Tarun Jha2-Apr-18 0:59 
GeneralRe: Creating a Simple Employee Database using inheritance in c++. Pin
Richard MacCutchan2-Apr-18 1:10
mveRichard MacCutchan2-Apr-18 1:10 
GeneralRe: Creating a Simple Employee Database using inheritance in c++. Pin
Tarun Jha2-Apr-18 2:32
Tarun Jha2-Apr-18 2:32 
AnswerRe: Creating a Simple Employee Database using inheritance in c++. Pin
Richard MacCutchan2-Apr-18 1:19
mveRichard MacCutchan2-Apr-18 1:19 
GeneralRe: Creating a Simple Employee Database using inheritance in c++. Pin
Tarun Jha2-Apr-18 1:19
Tarun Jha2-Apr-18 1:19 

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.