![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Expert Programmer
Join Date: Dec 2004
Posts: 794
Rep Power: 4
![]() |
Ah, that's what I was asking. I'm quite aware there are pointers in C, I was asking if there was func(T& foo, T& bar); and things like that. I guess not.
|
|
|
|
|
|
#12 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Kirk's example will not work as a C program.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#13 |
|
Programmer
|
Yeah, I hold my hands up to that. But anyway, the concept of what I said was right.
![]()
__________________
kirkl_uk Last edited by kirkl_uk; Jun 12th, 2005 at 3:51 PM. |
|
|
|
|
|
#14 |
|
Hobbyist Programmer
|
Thanks for all the help
![]() |
|
|
|
|
|
#15 | |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,260
Rep Power: 5
![]() |
Quote:
C++ has both concepts. C only has pointers. |
|
|
|
|
|
|
#16 |
|
Expert Programmer
Join Date: Dec 2004
Posts: 794
Rep Power: 4
![]() |
They ought to add references, I really like them.
|
|
|
|
|
|
#17 | |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,260
Rep Power: 5
![]() |
Quote:
![]() IIRC, it was debated by the C standards committee during development of the 1999 C standard. They decided against adding references as the only things most C programmers would want to do with them could be done with pointers. |
|
|
|
|
|
|
#18 |
|
Expert Programmer
Join Date: Dec 2004
Posts: 794
Rep Power: 4
![]() |
Yes, but I think it just looks so much nicer to see something like
change_variable_somehow(x); change_variable_somehow(&x); Oh, and on a semi-related note, is a pointer-to-function to f(T&); of the same type as one to f(T); ? |
|
|
|
|
|
#19 | ||
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,260
Rep Power: 5
![]() |
Quote:
Quote:
In C++, a pointer to a function f(T&) is of different type from a pointer to a function f(T). [PHP] typedef int ((*func1)(T &)); typedef int ((*func2)(T)); int f(T&); int f(T); int main() { func1 x(f); func2 y(f); if (x == y) // This comparison will cause a compiler error: func1 cannot be converted into a func2 { whatever(); } } [/PHP] [Oh, the joys of cross-fertilisation between C and C++ forums]. |
||
|
|
|
|
|
#20 |
|
Expert Programmer
Join Date: Dec 2004
Posts: 794
Rep Power: 4
![]() |
Thanks for the info.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|