473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

what does this do?

struct B: public A
{
int & b
B(int & a) : A(a), b(a){}
};

Is A(a), b(a) calling the constructor
I have never seen this syntax.

Would this be equivilent to

struct B: public A
{
int & b
B(int & a) : A(a), b(a){
super.A(a)
b=a
}
};

Thanks,

danny
Jul 23 '05 #1
2 1235
Danny wrote:
struct B: public A
{
int & b ^^^
A semicolon is probably missing here
B(int & a) : A(a), b(a){}
};

Is A(a), b(a) calling the constructor
I have never seen this syntax.
It's called "initialiser list". What book on C++ are you reading
that doesn't explain it?
Would this be equivilent to

struct B: public A
{
int & b
B(int & a) : A(a), b(a){
super.A(a)
b=a
}
};


No. There's no such thing as "super." in C++ and references cannot
be re-seated. And you seem to be missing all the semicolons except
the last one.

V
Jul 23 '05 #2

"Danny" <da******@kingkong.me.berkeley.edu> wrote in message
news:d4***********@agate.berkeley.edu...
struct B: public A
{
int & b
B(int & a) : A(a), b(a){}
};

Is A(a), b(a) calling the constructor
A(a) invokes a constructor, it doesn't "call" it.
I have never seen this syntax.

Would this be equivilent to

struct B: public A
{
int & b
B(int & a) : A(a), b(a){
super.A(a)
b=a
}
};

Thanks,

danny


Victor is right, you are missing the semi-colons to end the statements and
super isn't part of C++. However, the code you supplied is close to the Java
equivalent of a C++ class except you would be stating "super(a);" and Java
can't pass_by_reference. Since Java can only inherit from 1 base class,
super designates that base class (A).

No such restriction exists in C++. Any number of parent classes and
interfaces(pure-virtual) can be derived from.
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
3
by: Chris Cioffi | last post by:
I started writing this list because I wanted to have definite points to base a comparison on and as the starting point of writing something myself. After looking around, I think it would be a...
65
by: perseus | last post by:
I think that everyone who told me that my question is irrelevant, in particular Mr. David White, is being absolutely ridiculous. Obviously, most of you up here behave like the owners of the C++...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
3
by: Jukka K. Korpela | last post by:
I have noticed that the meaning of visibility: collapse has been discussed on different forums, but with no consensus on what it really means. Besides, implementations differ. The specification...
7
by: Dan V. | last post by:
Situation: I have to connect with my Windows 2000 server using VS.NET 2003 and C# and connect to a remote Linux server at another company's office and query their XML file. Their file may be...
44
by: lester | last post by:
a pre-beginner's question: what is the pros and cons of .net, compared to ++ I am wondering what can I get if I continue to learn C# after I have learned C --> C++ --> C# ?? I think there...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
tracyyun
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...
0
agi2029
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 projectplanning, coding, testing,...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.