Click here to Skip to main content
15,892,298 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
JokeRe: Get all substrings from an application Pin
CPallini1-Oct-12 21:10
mveCPallini1-Oct-12 21:10 
JokeRe: Get all substrings from an application Pin
Joan M2-Oct-12 23:22
professionalJoan M2-Oct-12 23:22 
GeneralRe: Get all substrings from an application Pin
CPallini2-Oct-12 23:25
mveCPallini2-Oct-12 23:25 
QuestionHow to get a C++ console application run in a terminal/powershell type of environment? Pin
infectedprof30-Sep-12 13:53
infectedprof30-Sep-12 13:53 
AnswerRe: How to get a C++ console application run in a terminal/powershell type of environment? Pin
Rajesh R Subramanian30-Sep-12 21:39
professionalRajesh R Subramanian30-Sep-12 21:39 
AnswerRe: How to get a C++ console application run in a terminal/powershell type of environment? Pin
jschell1-Oct-12 8:59
jschell1-Oct-12 8:59 
GeneralRe: How to get a C++ console application run in a terminal/powershell type of environment? Pin
infectedprof1-Oct-12 16:16
infectedprof1-Oct-12 16:16 
GeneralRe: How to get a C++ console application run in a terminal/powershell type of environment? Pin
jschell2-Oct-12 8:38
jschell2-Oct-12 8:38 
AnswerRe: How to get a C++ console application run in a terminal/powershell type of environment? Pin
Richard MacCutchan1-Oct-12 21:25
mveRichard MacCutchan1-Oct-12 21:25 
GeneralRe: How to get a C++ console application run in a terminal/powershell type of environment? Pin
infectedprof1-Oct-12 21:48
infectedprof1-Oct-12 21:48 
GeneralRe: How to get a C++ console application run in a terminal/powershell type of environment? Pin
Richard MacCutchan2-Oct-12 2:51
mveRichard MacCutchan2-Oct-12 2:51 
Questionproblem Pin
emanalshboul30-Sep-12 9:42
emanalshboul30-Sep-12 9:42 
AnswerRe: problem Pin
Albert Holguin1-Oct-12 4:09
professionalAlbert Holguin1-Oct-12 4:09 
QuestionGeneric Get and Set as interface Pin
Durga_Devi30-Sep-12 1:13
Durga_Devi30-Sep-12 1:13 
AnswerRe: Generic Get and Set as interface Pin
CPallini30-Sep-12 3:03
mveCPallini30-Sep-12 3:03 
AnswerRe: Generic Get and Set as interface Pin
pasztorpisti30-Sep-12 5:10
pasztorpisti30-Sep-12 5:10 
GeneralRe: Generic Get and Set as interface Pin
Durga_Devi30-Sep-12 8:13
Durga_Devi30-Sep-12 8:13 
GeneralRe: Generic Get and Set as interface Pin
pasztorpisti30-Sep-12 8:30
pasztorpisti30-Sep-12 8:30 
GeneralRe: Generic Get and Set as interface Pin
Durga_Devi30-Sep-12 22:13
Durga_Devi30-Sep-12 22:13 
GeneralRe: Generic Get and Set as interface Pin
pasztorpisti30-Sep-12 22:59
pasztorpisti30-Sep-12 22:59 
GeneralRe: Generic Get and Set as interface Pin
Durga_Devi3-Oct-12 10:14
Durga_Devi3-Oct-12 10:14 
HI pasztporpist

As per your input i have done the code
// App_Datatype.cpp : Defines the entry point for the console application.
//
#include <iostream>
#include <tchar.h>
#include <stdio.h>


class CStringValue;
class CValue
{
public:

	enum EType
    {
        EType_String,
        EType_Int,
    };


	virtual EType getDataType() = 0;

	virtual CStringValue* AsStringValue() { return NULL; }


};

class CStringValue : public CValue
{
private:
	std::string m_strValue;

public:

	void set(const std::string &strVal)
	{
		m_strValue = strVal;
	}

	std::string get()
	{
		return m_strValue;
	}

	CStringValue* AsStringValue()
	{
		return this;
	}

	EType getDataType()
	{
		return CValue::EType_String;
	}
};

void print(CValue *pVal)
{
	if(pVal->getDataType() == CValue::EType_String)
	{
		CStringValue *val = pVal->AsStringValue();
		std::cout<<val->get().c_str();
	}
}

int _tmain(int argc, _TCHAR* argv[])
{

	CStringValue *val = new CStringValue();
	val->set("Hai");

	print(val);

	return 0;
}


Is it correct? If not tell me where i did a mistake
GeneralRe: Generic Get and Set as interface Pin
pasztorpisti3-Oct-12 10:30
pasztorpisti3-Oct-12 10:30 
QuestionCrystal Report Win32 C++ in VS2010 Pin
simuytrix28-Sep-12 21:51
simuytrix28-Sep-12 21:51 
AnswerRe: Crystal Report Win32 C++ in VS2010 Pin
Richard MacCutchan28-Sep-12 22:11
mveRichard MacCutchan28-Sep-12 22:11 
AnswerRe: Crystal Report Win32 C++ in VS2010 Pin
Davide Zaccanti1-Oct-12 10:15
Davide Zaccanti1-Oct-12 10:15 

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.