Click here to Skip to main content
16,008,490 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CTreeview question Pin
monsieur_jj29-Jun-08 21:25
monsieur_jj29-Jun-08 21:25 
GeneralRe: CTreeview question Pin
Naveen29-Jun-08 21:48
Naveen29-Jun-08 21:48 
AnswerRe: CTreeview question Pin
Iain Clarke, Warrior Programmer30-Jun-08 2:20
Iain Clarke, Warrior Programmer30-Jun-08 2:20 
QuestionLNK2005 Error... Pin
Rizean29-Jun-08 13:52
Rizean29-Jun-08 13:52 
AnswerRe: LNK2005 Error... Pin
Stephen Hewitt29-Jun-08 15:14
Stephen Hewitt29-Jun-08 15:14 
GeneralRe: LNK2005 Error... Pin
Rizean29-Jun-08 15:24
Rizean29-Jun-08 15:24 
QuestionRe: LNK2005 Error... Pin
Mark Salsbery29-Jun-08 15:17
Mark Salsbery29-Jun-08 15:17 
AnswerRe: LNK2005 Error... Pin
Rizean29-Jun-08 15:45
Rizean29-Jun-08 15:45 
employee_template.h
#ifndef EMPLOYEE_TEMPLATE
#define EMPLOYEE_TEMPLATE

#include <iostream>
#include <string>
#include "stream_flush.h"

template <class T>
void _getInput(const std::string& message, T& result)
{
    std::cout << message;
    std::cin >> result;
    flush_istream(std::cin);
    if (std::cin.fail())
    {
        std::cin.clear();
        std::cout << "Invalid input!\n";
        _getInput<t>(message, result);
    }
}

#endif
</t>


employee.h Just defines the base class and does not include employee_template.h however employee.ccp does.

employee.ccp
#include "employee.h"
#include <string>
#include "employee_template.h"

using namespace std;

Employee::Employee()
{
    _getInput<string>("Please enter the employees first name: ", mFName);
    // more of the same
}

// _getInput is only used in the default constructor
}


researcher.h
#ifndef RESEARCHER_H
#define RESEARCHER_H

#include "employee.h"
#include <string>
#include <fstream>

class Researcher: public Employee
{
public:
    Researcher();
    Researcher(/* lots of stuff here */);
    // more of the same
};

#endif


researcher.cpp
#include "researcher.h"
#include <string>
#include <fstream>
#include "employee_template.h"

using namespace std;

Researcher::Researcher():Employee
{
    _getInput<string>("Enter the researcgers school: ", mSchool);
    // more of the same
}
//more of the same
};


I hope this helps and if you need more let me know. BTW, is there a way to cut and paste on Codeproject?

Edit: Errors from learning to post on CP... WTF | :WTF:
QuestionRe: LNK2005 Error... Pin
Mark Salsbery30-Jun-08 6:38
Mark Salsbery30-Jun-08 6:38 
AnswerRe: LNK2005 Error... Pin
Rizean30-Jun-08 13:54
Rizean30-Jun-08 13:54 
QuestionWhy does the line "delete [] player_data_array;" give a Debug Error Pin
tippex129-Jun-08 9:30
tippex129-Jun-08 9:30 
QuestionRe: Why does the line "delete [] player_data_array;" give a Debug Error Pin
Mark Salsbery29-Jun-08 9:46
Mark Salsbery29-Jun-08 9:46 
AnswerRe: Why does the line "delete [] player_data_array;" give a Debug Error Pin
tippex129-Jun-08 10:08
tippex129-Jun-08 10:08 
GeneralRe: Why does the line "delete [] player_data_array;" give a Debug Error [modified] Pin
Mark Salsbery29-Jun-08 10:15
Mark Salsbery29-Jun-08 10:15 
GeneralRe: Why does the line "delete [] player_data_array;" give a Debug Error Pin
tippex129-Jun-08 11:29
tippex129-Jun-08 11:29 
GeneralRe: Why does the line "delete [] player_data_array;" give a Debug Error Pin
Mark Salsbery29-Jun-08 11:49
Mark Salsbery29-Jun-08 11:49 
GeneralRe: Why does the line "delete [] player_data_array;" give a Debug Error Pin
tippex11-Jul-08 3:27
tippex11-Jul-08 3:27 
GeneralRe: Why does the line "delete [] player_data_array;" give a Debug Error Pin
Mark Salsbery1-Jul-08 6:35
Mark Salsbery1-Jul-08 6:35 
GeneralRe: Why does the line "delete [] player_data_array;" give a Debug Error Pin
Stephen Hewitt29-Jun-08 15:15
Stephen Hewitt29-Jun-08 15:15 
QuestionIssue with calling the MessageBox Windows API from a DLL Pin
jbf15429-Jun-08 8:19
jbf15429-Jun-08 8:19 
AnswerRe: Issue with calling the MessageBox Windows API from a DLL Pin
dave_mm04-Dec-08 10:03
dave_mm04-Dec-08 10:03 
GeneralRe: Issue with calling the MessageBox Windows API from a DLL Pin
jbf1544-Dec-08 16:23
jbf1544-Dec-08 16:23 
QuestionNetwork programming (problem)???my server software is giving connection established but my client software is giving socket init failed Pin
bodhi201629-Jun-08 6:25
bodhi201629-Jun-08 6:25 
AnswerRe: Network programming (problem)???my server software is giving connection established but my client software is giving socket init failed Pin
Mark Salsbery29-Jun-08 8:18
Mark Salsbery29-Jun-08 8:18 
QuestionNeed Help... Pin
Rozz1829-Jun-08 0:36
Rozz1829-Jun-08 0:36 

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.