If a class is defined in a header file with the appropriate signatures,
is it possible to add private helper functions in the cpp file that were
not defined in the header file?
If not, are we supposed to add any helper functions as global functions?
Thanks
You cannot add helper functions that will be able to see private
sections of the class without modifying the header file.
So far I did not see a particular need for helpers (sure, the - and *
are a bit long but there isn't much you can outsource).
Thanks.
So in general, once the header file for a c++ class is defined, the
functions for the class are set in stone?
ie..
Foo.h:
class Foo {
public:
bar();
private:
baz();
}
There is no way to add any private functions in Foo.cpp that are not
declared in the header file?
Nope, no way that I know of anyways.
Yes, but you *can* add free routines to the .cc file that will not be
visible outside.
>> ie..
>>
>> Foo.h:
>>
>>
>> class Foo {
>> public:
>> bar();
>> private:
>> baz();
>>
>> }
For example:
Foo.cc
void helper() {...}
void Foo::bar() { helper; }
...
>> There is no way to add any private functions in Foo.cpp that are not
>> declared in the header file?
>
>Nope, no way that I know of anyways.
Not if you want them to be part of the class, no.
--
--
Caroline Kierstead, Undergraduate Operations Coordinator
David R. Cheriton School of Computer Science
University of Waterloo, DC3122 (519) 888-4567 x36226