473,902 Members | 5,194 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Alias for a std::vector

I am trying to refer to the same std::vector in a class by two different names,
I tried a union, and I tried a reference, I can't seem to get the syntax right.
Can anyone please help? Thanks
Aug 16 '06
56 5857

"Victor Bazarov" <v.********@com Acast.netwrote in message
news:eb******** **@news.datemas .de...
Peter Olcott wrote:
>[..]
The basic idea works, yet I don't know the required syntax for all of
my other constructors.
What is the syntax for an initializer list when the constructor has
parameters?

What book are you reading that doesn't describe parameterized c-tors
and their initialiser lists????
I figured it out. It was not merely parameterized constructors with
initialization lists, I have done this before. It was the case where the
constructor has a body far too large to be contained in the declaration. I
intentionally avoided paying attention to initialization lists because IMO they
represent bad (non orthogonal) language design.

>
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask

Aug 17 '06 #21
In article <zIQEg.929$Tl4. 354@dukeread06> , Peter Olcott <ol****@att.net wrote:
>"Victor Bazarov" <v.********@com Acast.netwrote in message
news:eb******* ***@news.datema s.de...
>Peter Olcott wrote:
>>[..]
The basic idea works, yet I don't know the required syntax for all of
my other constructors.
What is the syntax for an initializer list when the constructor has
parameters?

What book are you reading that doesn't describe parameterized c-tors
and their initialiser lists????

I figured it out. It was not merely parameterized constructors with
initializati on lists, I have done this before. It was the case where the
constructor has a body far too large to be contained in the declaration. I
intentionall y avoided paying attention to initialization lists because IMO they
represent bad (non orthogonal) language design.
I don't understand. What you did was to ignore a cornerstone
feature of initialization because it was deemed bad language
design (why do you think so??) only to introduce same on another
level. Also, on this note, if the body of the ctor is so far
too large that may also be problematic in its own right.
--
Greg Comeau / 20 years of Comeauity! Intel Mac Port now in alpha!
Comeau C/C++ ONLINE == http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Aug 17 '06 #22

"Greg Comeau" <co****@panix.c omwrote in message
news:ec******** **@panix2.panix .com...
In article <zIQEg.929$Tl4. 354@dukeread06> , Peter Olcott <ol****@att.net >
wrote:
>>"Victor Bazarov" <v.********@com Acast.netwrote in message
news:eb****** ****@news.datem as.de...
>>Peter Olcott wrote:
[..]
The basic idea works, yet I don't know the required syntax for all of
my other constructors.
What is the syntax for an initializer list when the constructor has
parameters ?

What book are you reading that doesn't describe parameterized c-tors
and their initialiser lists????

I figured it out. It was not merely parameterized constructors with
initializatio n lists, I have done this before. It was the case where the
constructor has a body far too large to be contained in the declaration. I
intentional ly avoided paying attention to initialization lists because IMO
they
represent bad (non orthogonal) language design.

I don't understand. What you did was to ignore a cornerstone
feature of initialization because it was deemed bad language
design (why do you think so??) only to introduce same on another
It is bad language design (non orthogonal) because there are two entirely
different syntax ways of doing this. Initialization lists and assignment, the
former being the oddball.
level. Also, on this note, if the body of the ctor is so far
too large that may also be problematic in its own right.
--
Greg Comeau / 20 years of Comeauity! Intel Mac Port now in alpha!
Comeau C/C++ ONLINE == http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?

Aug 17 '06 #23
Peter Olcott schrieb:
"Greg Comeau" <co****@panix.c omwrote in message
>I don't understand. What you did was to ignore a cornerstone
feature of initialization because it was deemed bad language
design (why do you think so??) only to introduce same on another

It is bad language design (non orthogonal) because there are two entirely
different syntax ways of doing this. Initialization lists and assignment, the
former being the oddball.
There are "two different syntax ways" for normal types:

int *pi = new int(5);
int i(5); // both: initialize i to 5

i = 5; // assign/reset i to 5

So there are two different ways for class members, too. It is not bad
language design, it is quite necessary.

By the way:

int& refi(i); // initialize int&
const int ci(7); // initialize const int

refi = &i; // can't bind to another object
ci = 11; // not possible, it's const

So references and const member variables have to use initialization list,
since assignment is not possible.

--
Thomas
Aug 17 '06 #24
Peter Olcott wrote:
[..]
It is bad language design (non orthogonal) because there are two
entirely different syntax ways of doing this. Initialization lists
and assignment, the former being the oddball.
Very sorry to hear (read) that. You apparently do not understand
the difference. Read the FAQ, read more good books.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 17 '06 #25

Peter Olcott wrote:
"Greg Comeau" <co****@panix.c omwrote in message
<snip>
I don't understand. What you did was to ignore a cornerstone
feature of initialization because it was deemed bad language
design (why do you think so??) only to introduce same on another

It is bad language design (non orthogonal) because there are two entirely
different syntax ways of doing this. Initialization lists and assignment, the
former being the oddball.
You are aware that initialisation and assignment are two entirely
different things aren't you? It seems odd to object that two entirely
different concepts have entirely different syntax.

Gavin Deane

Aug 17 '06 #26

"Thomas J. Gritzan" <Ph************ *@gmx.dewrote in message
news:ec******** *@newsreader2.n etcologne.de...
Peter Olcott schrieb:
>"Greg Comeau" <co****@panix.c omwrote in message
>>I don't understand. What you did was to ignore a cornerstone
feature of initialization because it was deemed bad language
design (why do you think so??) only to introduce same on another

It is bad language design (non orthogonal) because there are two entirely
different syntax ways of doing this. Initialization lists and assignment, the
former being the oddball.

There are "two different syntax ways" for normal types:

int *pi = new int(5);
int i(5); // both: initialize i to 5

i = 5; // assign/reset i to 5

So there are two different ways for class members, too. It is not bad
language design, it is quite necessary.
It is not necessary at all. One syntactic way of specifying anything is all that
is required. Whenever there is more than one syntactic way of specifying
anything, additional unnecessary learning curve is created. Language design
should favor the language user over the compiler writer by the same ratio of
language users to compiler writers, thus if the compiler writer has a 1,000 fold
greater burden to save the language user 0.1% effort, this is a good tradeoff.
>
By the way:

int& refi(i); // initialize int&
const int ci(7); // initialize const int

refi = &i; // can't bind to another object
ci = 11; // not possible, it's const

So references and const member variables have to use initialization list,
since assignment is not possible.

--
Thomas

Aug 17 '06 #27

"Gavin Deane" <de*********@ho tmail.comwrote in message
news:11******** **************@ 75g2000cwc.goog legroups.com...
>
Peter Olcott wrote:
>"Greg Comeau" <co****@panix.c omwrote in message

<snip>
I don't understand. What you did was to ignore a cornerstone
feature of initialization because it was deemed bad language
design (why do you think so??) only to introduce same on another

It is bad language design (non orthogonal) because there are two entirely
different syntax ways of doing this. Initialization lists and assignment, the
former being the oddball.

You are aware that initialisation and assignment are two entirely
different things aren't you? It seems odd to object that two entirely
different concepts have entirely different syntax.

Gavin Deane
Initialization is merely the first assignment.
Aug 17 '06 #28

Peter Olcott wrote:
"Gavin Deane" <de*********@ho tmail.comwrote in message
You are aware that initialisation and assignment are two entirely
different things aren't you? It seems odd to object that two entirely
different concepts have entirely different syntax.

Initialization is merely the first assignment.
If you read that in a book, throw the book away. If you read it on a
website, delete the website from your list of favourites. Search the
history of this group for countless discussions of the difference
between initialisation and assignment.

You've already discovered that with a class member of reference type,
by the time you first get the chance to assign to it, the opportunity
to initialise it (and references must be initialised) has been missed
and so the code cannot be correct.

Gavin Deane

Aug 17 '06 #29

Thomas J. Gritzan wrote:
So references and const member variables have to use initialization list,
since assignment is not possible.
It is perfectly possible to assign to a (non-const) reference and
thereby reseat it, including reference class members. What is not
possible is to leave a reference member out of the initialiser list and
reseat it in the constructor body by assignment, for the same reason
that this is not allowed

int main()
{
int& i;
}

References are not allowed to refer to nothing when they are created.

Gavin Deane

Aug 17 '06 #30

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

Similar topics

20
17881
by: Anonymous | last post by:
Is there a non-brute force method of doing this? transform() looked likely but had no predefined function object. std::vector<double> src; std::vector<int> dest; std::vector<double>::size_type size = src.size(); dest.reserve(size); for (std::vector<int>::size_type i = 0;
32
69733
by: zl2k | last post by:
hi, c++ user Suppose I constructed a large array and put it in the std::vector in a function and now I want to return it back to where the function is called. I can do like this: std::vector<int> fun(){ //build the vector v; return v; }
21
2219
by: Peter Olcott | last post by:
I got the previous alias to std::vector working, and found that it takes up the space of a pointer. I want to find a way to do an alias to a std::vector that does not take up any space. Is there any way to do this? (I tried #define Name1 Name2 and it didn't compile)
0
9845
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,...
0
10872
jinu1996
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...
1
10981
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,...
1
8047
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 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...
0
7205
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();...
0
5893
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...
0
6085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4307
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3323
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.