Is it possible to write: int&(&fn)(int& arg);? Thanks!!! 11 1451
Protoman wrote: Is it possible to write: int&(&fn)(int& arg);? Thanks!!!
Yes, you just have...
Protoman wrote: Is it possible to write: int&(&fn)(int& arg);? Thanks!!!
Yes.
V
Protoman wrote: Is it possible to write: int&(&fn)(int& arg);? Thanks!!!
No its not possible.
References need to be initialized when defined. Your expression ends in
a semicolon which will give non-initialization error.
You can do this -
int& foo(int & x);
int&(&fn)(int& arg) = foo;
This will work.
> No its not possible. References need to be initialized when defined. Your expression ends in a semicolon which will give non-initialization error.
You can do this -
int& foo(int & x);
int&(&fn)(int& arg) = foo;
This will work.
The OP might have meant:
struct whatever{
////
int& (&fn)(int& arg);
whatever: fn(some_fn){}
};
Ben
benben wrote: The OP might have meant:
struct whatever{
//// int& (&fn)(int& arg);
whatever: fn(some_fn){} };
OK, I missed the context !!
Neelesh Bodas wrote: benben wrote:
The OP might have meant:
struct whatever{
//// int& (&fn)(int& arg);
whatever: fn(some_fn){} };
OK, I missed the context !!
No, you didn't. There was no context to miss.
"benben" <be******@yahoo.com.au> wrote in message
news:43***********************@news.optusnet.com.a u... No its not possible. References need to be initialized when defined. Your expression ends in a semicolon which will give non-initialization error.
You can do this -
int& foo(int & x);
int&(&fn)(int& arg) = foo;
This will work.
The OP might have meant:
struct whatever{
//// int& (&fn)(int& arg);
whatever: fn(some_fn){}
Did you mean...
whatever() : fn(some_fn) {}
? (The parentheses are required, aren't they?)
-Howard
I know it is possible, but it seems too weird for me.
I never have seen it in production code.
Is there a reason for doing that?
Do C++ have references to members, too? ;-)
On 2005-12-13, Diego Martins <jo********@gmail.com> wrote: I know it is possible, but it seems too weird for me.
I never have seen it in production code.
Is there a reason for doing that?
I can't think of one. Since a function can't be an lvalue, what's
the point of having a reference to one?
Do C++ have references to members, too? ;-)
Yep.
--
Neil Cerutti
Neil Cerutti wrote: On 2005-12-13, Diego Martins <jo********@gmail.com> wrote:
I know it is possible, but it seems too weird for me.
I never have seen it in production code.
Is there a reason for doing that?
I can't think of one. Since a function can't be an lvalue, what's the point of having a reference to one?
Do C++ have references to members, too? ;-)
Yep.
Really? I just searched the Standard for "reference to member" and it
found one occurrence of that phrase on page 137, in a note (not in the
normative part, but still). The exact sentence is
<<... There is no "reference to member" type in C++. >> (see 8.3.3/3)
V
On 2005-12-13, Victor Bazarov <v.********@comAcast.net> wrote: Neil Cerutti wrote: On 2005-12-13, Diego Martins <jo********@gmail.com> wrote:
I know it is possible, but it seems too weird for me.
I never have seen it in production code.
Is there a reason for doing that?
I can't think of one. Since a function can't be an lvalue, what's the point of having a reference to one?
Do C++ have references to members, too? ;-)
Yep.
Really? I just searched the Standard for "reference to member" and it found one occurrence of that phrase on page 137, in a note (not in the normative part, but still). The exact sentence is <<... There is no "reference to member" type in C++. >> (see 8.3.3/3)
Well, maybe not. ;-)
Seriously, thanks for the correction. I thinking of references to
objects that happen to be members, which are just references.
--
Neil Cerutti This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Weston C |
last post by:
I'm trying to write a generic/reusable form validator in Javascript...
just something that checks to make sure required fields have a value. By
generic I mean I don't want to explicitly reference...
|
by: m sergei |
last post by:
main(int argc, char *argv)
the second parameter, argv, to function main takes a pointer to an array.
can we also write it in terms of a reference rather than a pointer ? (like &..)
|
by: Scott |
last post by:
I need help to modify the code below to pass url variables from a
framset. The click to run this will be in the mainFrame.
This script works well in a non-frame page. Grabs the current url...
|
by: Eli |
last post by:
I've got a script that I'm trying to debug which uses document.write()
to place HTML within a page. In both IE6 and Firefox when I view
source, I see only the script itself and not any HTML as...
|
by: news |
last post by:
I'm trying to encapsulate a bunch of html widgets such that a
containing page can call them to draw themselves in whatever order it
chooses as well as easily add new ones.
In order to do this...
|
by: Ritu |
last post by:
Hi All,
Can any body please tell me how i can write a device driver using CSharp.
Thanks,
Ritu
|
by: Michael |
last post by:
Hello,
I have a separate Database class that handles any database work that all my
asp.net pages can use.
My problem is, many times I use try/catch to catch errors, and I want to
output these...
|
by: Dr. Zharkov |
last post by:
We have program Visual Basic .NET 2003 for construction of 3D-Graphics as a
surface z=f (x, y). From VB .NET 2003 we want to transfer coordinates of
this surface as myArrayVB (2000, 1) in myArrayVó...
|
by: Ron |
last post by:
Hello,
I need 2 projects/apps to communicate with each other. I
figured out how to create a Class Library project with a
form and how to add a new exe project to the solution. I
set the...
|
by: Bill Cunningham |
last post by:
I don't think I can do this without some help or hints. Here is the code
I have.
#include <stdio.h>
#include <stdlib.h>
double input(double input) {
int count=0,div=0;
double...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |