How can I return a pointer to the class Foo using its functions. The reason I'm asking is because I want this code to work
Class fo fo.MakeA(34.5777).MakeY(73.8843);
Thank you in advance
Assuming you need a reference return type;
class foo { public: foo& MakeA(float a) { // MakeA code logic here... return *this; } foo& MakeB(float b) { // MakeA code logic here... return *this; } }
Otherwise, you can simply return a copy ( foo instead of foo& ).
foo
foo&
You want to use an indexer for your class.
Make the return type for (MakeA, MakeY) the same data type as the class (with ref &).
and at the end of each method put
return *this;