[ create a new paste ] login | about

Link: http://codepad.org/HtoXPyZP    [ raw code | output | fork ]

hecomi - C++, pasted on Mar 15:
#include <iostream>
#include <string>

class CompanyA
{
public:
	void sendCleartext(const std::string& msg)
	{
		std::cout << msg << std::endl;
	}
};

class MsgInfo
{
public:
	std::string getMsg() const
	{
		return "hoge";
	}
};

template<typename Company>
class MsgSender
{
public:
	void sendClear(const MsgInfo& info)
	{
		std::string msg = info.getMsg();
		Company c;
		c.sendCleartext(msg);
	}
};

template<typename Company>
class LoggingMsgSender: public MsgSender<Company>
{
public:
	LoggingMsgSender() {}
	void sendClearMsg(const MsgInfo& info)
	{
		sendClear(info);
	}
};

int main()
{
	LoggingMsgSender<CompanyA> a;
	MsgInfo info;
	a.sendClearMsg(info);
	return 0;
}


Output:
1
2
3
t.cpp: In member function 'void LoggingMsgSender<Company>::sendClearMsg(const MsgInfo&)':
Line 41: error: there are no arguments to 'sendClear' that depend on a template parameter, so a declaration of 'sendClear' must be available
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: