Creating an assigning an object in c++ -
hello new c++,
i can create new instance of class using example example("123")
i have 2 question
i know cannot check if object null
if(example ==null)
because not pointer have other way that.i have method return object like: how can return null?
example get_example() { if (example.getname().empty() { example example("345"); return example; } return null // cannot return null. }
can this?
example get_example() { example example; if (example.getname().empty() { example = example example("345"); return example; } return null // cannot return null. how }
example = example example("345");
know stupid how can without pointer.
use pointers,
example *ex = null
.construct default
null_example
, overload==
example e; if (e == null_example) { e.init(); }
but provide
is_init()
function.example e; if (!e.is_init()) { e.init(); }
you
get_example
like:void get_example(example &e) { // method2 or method3 }
Comments
Post a Comment