Two differents types; Foo type and pointer type. Need function
overload foe each or just use ref and avoid pointer.
On Tuesday, 15 December 2020 at 20:38:04 UTC, Dave P. wrote:
The use case would be to define extension methods on a struct
outside of where the struct is defined. The extension method
mutates the state of the struct, so I want to ensure I am
modifying the original struct and not a copy. If
On Wednesday, 16 December 2020 at 03:50:07 UTC, Mike Parker wrote:
On Sunday, 13 December 2020 at 19:02:34 UTC, Dave P. wrote:
On Sunday, 13 December 2020 at 18:44:20 UTC, Mike Parker wrote:
On Sunday, 13 December 2020 at 18:31:54 UTC, Dave P. wrote:
[...]
Based on you requirement to use
On Sunday, 13 December 2020 at 19:02:34 UTC, Dave P. wrote:
On Sunday, 13 December 2020 at 18:44:20 UTC, Mike Parker wrote:
On Sunday, 13 December 2020 at 18:31:54 UTC, Dave P. wrote:
Do I have to write both and have one forward to the other for
more
complicated functions?
For free
On Tuesday, 15 December 2020 at 19:45:50 UTC, Q. Schroll wrote:
On Sunday, 13 December 2020 at 19:02:34 UTC, Dave P. wrote:
On Sunday, 13 December 2020 at 18:44:20 UTC, Mike Parker wrote:
On Sunday, 13 December 2020 at 18:31:54 UTC, Dave P. wrote:
Do I have to write both and have one forward
On Sunday, 13 December 2020 at 19:02:34 UTC, Dave P. wrote:
On Sunday, 13 December 2020 at 18:44:20 UTC, Mike Parker wrote:
On Sunday, 13 December 2020 at 18:31:54 UTC, Dave P. wrote:
Do I have to write both and have one forward to the other for
more
complicated functions?
For free
On Sunday, 13 December 2020 at 18:44:20 UTC, Mike Parker wrote:
On Sunday, 13 December 2020 at 18:31:54 UTC, Dave P. wrote:
Do I have to write both and have one forward to the other for
more
complicated functions?
For free functions, yes.
Is there any way to write the function as a
On Sunday, 13 December 2020 at 18:31:54 UTC, Dave P. wrote:
If I define a method on a type, then I can call it both through
a pointer and
through a reference and the compiler does the right thing. Eg:
struct Foo {
int x;
void fooey(){
x++;
}
void report(){
If I define a method on a type, then I can call it both through a
pointer and
through a reference and the compiler does the right thing. Eg:
struct Foo {
int x;
void fooey(){
x++;
}
void report(){
printf("%d\n", x);
}
}
int main(){
Foo f;
f.fooey;