I wish I had an example so I could demonstrate. This is something I've
wanted to understand for a long time, but every time I've hit it, I've been
too busy to stop and investigate. Sometimes when I try to construct
objects of class type, I end up with weird things that look like
foo().fun(). I believe it happens like this:
Foo foo();
foo.fun();
After the call to foo.fun(); I get an error showing me I have some kind of
object called foo(). If I don't use the "()" in the constructor, that
fixes the problem. Does anybody know what I'm talking about?
--
NOUN:1. Money or property bequeathed to another by will. 2. Something handed
down from an ancestor or a predecessor or from the past: a legacy of
religious freedom. ETYMOLOGY: MidE legacie, office of a deputy, from OF,
from ML legatia, from L legare, to depute, bequeath. www.bartleby.com/61/ 5 1445
Hi
Steven T. Hatton wrote:
Foo foo();
foo.fun();
After the call to foo.fun(); I get an error showing me I have some kind of
object called foo(). If I don't use the "()" in the constructor, that
fixes the problem. Does anybody know what I'm talking about?
Yes, you are looking for: http://www.parashift.com/c++-faq-lit....html#faq-10.2
Markus
"Markus Moll" <mo**@rbg.infor matik.tu-darmstadt.dewro te in message
news:45******** **************@ newsspool3.arco r-online.net...
Hi
Steven T. Hatton wrote:
Foo foo();
foo.fun();
After the call to foo.fun(); I get an error showing me I have some kind
of
object called foo(). If I don't use the "()" in the constructor, that
fixes the problem. Does anybody know what I'm talking about?
Yes, you are looking for: http://www.parashift.com/c++-faq-lit....html#faq-10.2
Markus
And this, which explains it better: http://www.parashift.com/c++-faq-lit...html#faq-10.19
Steven T. Hatton wrote:
Sometimes when I try to construct objects of class type, I end up
with weird things. I believe it happens like this:
Foo foo();
This is not the correct syntax to construct an object of class type.
(Spending too much time on Java?)
foo.fun();
After the call to foo.fun(); I get an error showing me I have some kind of
object called foo(). If I don't use the "()" in the constructor, that
fixes the problem.
Foo foo;
is the correct syntax for constructing an object via the default
constructor.
Old Wolf wrote:
Steven T. Hatton wrote:
>Sometimes when I try to construct objects of class type, I end up with weird things. I believe it happens like this:
Foo foo();
This is not the correct syntax to construct an object of class type.
(Spending too much time on Java?)
>foo.fun();
After the call to foo.fun(); I get an error showing me I have some kind of object called foo(). If I don't use the "()" in the constructor, that fixes the problem.
Foo foo;
is the correct syntax for constructing an object via the default
constructor.
There has to be more to this, because it rarely happens to me. I'll have to
wait till it happens again to see if I can figure out why I'm doing things
differently, or why the code is acting unusually. It may simply be
flashbacks to Java. But I think there's more to it. I believe it has
happened when I do something like:
Blah * blah_ptr(new Blah());
//but
Blah * blah_ptr(new Blah);
//works.
The pointers to the FAQ were informative. They may even answer the whole
question.
--
NOUN:1. Money or property bequeathed to another by will. 2. Something handed
down from an ancestor or a predecessor or from the past: a legacy of
religious freedom. ETYMOLOGY: MidE legacie, office of a deputy, from OF,
from ML legatia, from L legare, to depute, bequeath. www.bartleby.com/61/
"Steven T. Hatton" <ch********@ger mania.supwrote in message
news:Nt******** *************** *******@speakea sy.net
Old Wolf wrote:
>Steven T. Hatton wrote:
>>Sometimes when I try to construct objects of class type, I end up with weird things. I believe it happens like this:
Foo foo();
This is not the correct syntax to construct an object of class type. (Spending too much time on Java?)
>>foo.fun();
After the call to foo.fun(); I get an error showing me I have some kind of object called foo(). If I don't use the "()" in the constructor, that fixes the problem.
Foo foo;
is the correct syntax for constructing an object via the default constructor.
There has to be more to this, because it rarely happens to me. I'll
have to wait till it happens again to see if I can figure out why I'm
doing things differently, or why the code is acting unusually. It
may simply be flashbacks to Java. But I think there's more to it. I
believe it has happened when I do something like:
Blah * blah_ptr(new Blah());
//but
Blah * blah_ptr(new Blah);
//works.
You are allowed to have brackets when you use new, but not when you don't
use new (since the use of new enables the compiler to better distinguish
your intent).
struct S
{
S()
{cout << "S default constructor\n"; }
};
struct Foo
{
Foo(S *ptr)
{ cout << "Foo\n";}
};
struct Goo
{
Goo(const S & ref)
{
cout << "Goo\n";
}
};
int main()
{
Foo foo(new S()); // works OK
Goo goo(S()); // function declaration with no effect
return 0;
}
--
John Carson This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Michele Simionato |
last post by:
So far, I have not installed Prothon, nor I have experience with Io, Self
or other prototype-based languages. Still, from the discussion on the
mailing list, I have got the strong impression that you do not actually
need to fork Python in order to implement prototypes. It seems to me
that Python metaclasses + descriptors are more than powerful enough to
implementing prototypes in pure Python.
I wrote a module that implements part of what...
|
by: Jacek Dziedzic |
last post by:
Hi!
First of all, I hope my problem is not too loosely tied to the
"standard C++" that is the topic of this group.
I have some code that exhibits a strange behaviour: on
one computer, where I compile with g++-3.2 it compiles and
works fine, on another computer, whether I compile with g++-3.0
or g++-2.95 (unfortunately 3.2 is not available) it crashes
with a segmentation violation on runtime.
|
by: Daz |
last post by:
Hi everyone.
My query is very straight forward (I think).
What's the difference between
someFunc.blah = function(){ ; }
and
|
by: Jorge |
last post by:
Why is it listed here :
http://www.crockford.com/javascript/recommend.html
under "deprecation" ?
Without it, how is an anonymous function() going to call itself
(recursively) ?
I use to write timers like this :
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |