你好,我是c++的新手,
我可以使用Example example("123")创建类的新实例
我有两个问题
if(example ==NULL),因为这不是一个指针,我们还有其他方法可以做到这一点。我能做这样的事吗?
Example get_Example() {
Example example;
if (example.getName().empty() {
example = Example example("345");
return example;
}
return NULL // i cannot return null. How
}example = Example example("345");,我知道这很愚蠢,但是没有指针我怎么做呢?
发布于 2013-05-04 14:23:54
Example *ex = NULL。null_example并重载==示例e;if (e == null_example) { e.init();}
is_init()函数。
示例e;if (!e.is_init()) { e.init();}get_example可能是这样的:
空get_example(例如&e) { // method2或method3 }https://stackoverflow.com/questions/16375223
复制相似问题