对于许多问题,答案似乎可以在"标准"中找到.但是,我们在哪里找到它?最好是在线.
谷歌搜索有时会觉得徒劳,尤其是对于C标准,因为他们在编程论坛的大量讨论中被淹没.
要开始这个,因为这些是我现在正在搜索的,那里有很好的在线资源:
我试图超载operator <<,但它总是需要成为一个const功能.但是,我想更改此重载函数中的值.我该怎么做呢?
EDIT1:代码存根如下所示:
class Check
{
public:
void operator << (boost::any)
{
// checks weather the given is hresult,string(filename) or int(line no)
// and dump them into the exception object,
// There by hresult will initiate the object and int will throw the object.
// so the input order must be like below
}
private:
Exception exception;
};
Run Code Online (Sandbox Code Playgroud)
用法
Check check;
check << file->open << __FILE__ << __LINE__ ;
Run Code Online (Sandbox Code Playgroud)
编辑2:这是谁曾经说过语法不好实现我不是一个很好的exp.程序员.我只是试图快速解决异常问题.我的动机是它不应该消耗更多的时间,它应该很容易打字.因为我的同事必须使用这个异常类.我试图找到一个解决方案,答案来自<<运算符重载.例如,考虑以下示例
1)我的方法
#define INFO __LINE__ …Run Code Online (Sandbox Code Playgroud)