Monday, July 27, 2009

comp.lang.c++ - 21 new messages in 10 topics - digest

comp.lang.c++
http://groups.google.com/group/comp.lang.c++?hl=en

comp.lang.c++@googlegroups.com

Today's topics:

* China factory wholesale NFL,mlb,nhl,nba Jerseys Free Shipping Paypal payment
<www.wtojerseys.com> - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/063ec2aa368da682?hl=en
* Need to use "volatile" for accessing variables between threads? - 3 messages,
3 authors
http://groups.google.com/group/comp.lang.c++/t/4e68d5b929c344d4?hl=en
* Wow, This Is So Sad... - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/c6f3bb73a9d27bc1?hl=en
* How to write previous element in STL list - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/2d136691c93121bf?hl=en
* "Concepts" were removed from C++0x - 4 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/2a650fa1f3c8016a?hl=en
* ┈━═☆ www.fjrjtrade.com Wholesale many brand Stock Sunglass,goggle (paypal
payment) + (free shipping) - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/5d5157dfd6b41188?hl=en
* passing by reference - 5 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/44dae30d52f6c6db?hl=en
* The recession and you: has the economy changed your IT spending? - 1
messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/1c7bb5179e756029?hl=en
* How can I use unqualified names? (Possibly hard or impossible?) - 2 messages,
2 authors
http://groups.google.com/group/comp.lang.c++/t/e2f24a95fe72b591?hl=en
* dealing with lower level programmers - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/f708a2c0cfa8ce2d?hl=en

==============================================================================
TOPIC: China factory wholesale NFL,mlb,nhl,nba Jerseys Free Shipping Paypal
payment <www.wtojerseys.com>
http://groups.google.com/group/comp.lang.c++/t/063ec2aa368da682?hl=en
==============================================================================

== 1 of 2 ==
Date: Mon, Jul 27 2009 10:39 am
From: hehe


ALL ARE IN HAND,FAST SHIPMENT!


We use EMS,it usually takes 4-7 days arrive your hand!
BRAND NEW WITH tAG (NWT)
FASTEST SHIPPING PROMIS
SIZE:M,L,XL,XXL48,50,52,54
M48:81--65cm(length-width)
L50:83--66cm(length-width)
XL52:85--67cm(length-width)
XXL54:88--67cm( length-width)


We offer money back(not include shipment) guarantee on all my
jerseys,
if you are not happy you can return it for a FULL REFUND as long as
the item is in the same condition that you received.
ALL LETTERS AND NUMBERS ARE SEWN ON!!!


High Quality Promised!!!


and you can mix the order!!!


Arizona Cardinals(www.wtojerseys.com)
Atlanta Falcons(www.wtojerseys.com)
Baltimore Ravens(www.wtojerseys.com)
Buffalo Bills(www.wtojerseys.com)
Carolina Panthers(www.wtojerseys.com)
Chicago Bears(www.wtojerseys.com)
Cincinnati Bengals(www.wtojerseys.com)
Cleveland Browns(www.wtojerseys.com)
Dallas Cowboys(www.wtojerseys.com)
Denver Broncos(www.wtojerseys.com)
Detroit Lions(www.wtojerseys.com)
Green Bay Packers(www.wtojerseys.com)
Houston Texans(www.wtojerseys.com)
Indianapolis Colts(www.wtojerseys.com)
Jacksonville Jaguars(www.wtojerseys.com)
Kansas City Chiefs(www.wtojerseys.com)
Miami Dolphins(www.wtojerseys.com)
Minnesota Vikings(www.wtojerseys.com)
New England Patriots(www.wtojerseys.com)
New Orleans Saints(www.wtojerseys.com)
New York Giants(www.wtojerseys.com)
San Francisco 49ers(www.wtojerseys.com)
Seattle Seahawks(www.wtojerseys.com)
St. Louis Rams(www.wtojerseys.com)
Tampa Bay Buccaneers(www.wtojerseys.com)
Tennessee Titans(www.wtojerseys.com)
Washington Redskins(www.wtojerseys.com)
New York Jets(www.wtojerseys.com)
Oakland Raiders(www.wtojerseys.com)
Philadelphia Eagles(www.wtojerseys.com)
Pittsburgh Steelers(www.wtojerseys.com)
San Diego Chargers(www.wtojerseys.com)


== 2 of 2 ==
Date: Mon, Jul 27 2009 11:01 am
From: asd


ALL ARE IN HAND,FAST SHIPMENT!


We use EMS,it usually takes 4-7 days arrive your hand!
BRAND NEW WITH tAG (NWT)
FASTEST SHIPPING PROMIS
SIZE:M,L,XL,XXL48,50,52,54
M48:81--65cm(length-width)
L50:83--66cm(length-width)
XL52:85--67cm(length-width)
XXL54:88--67cm( length-width)


We offer money back(not include shipment) guarantee on all my
jerseys,
if you are not happy you can return it for a FULL REFUND as long as
the item is in the same condition that you received.
ALL LETTERS AND NUMBERS ARE SEWN ON!!!


High Quality Promised!!!


and you can mix the order!!!


Arizona Cardinals(www.wtojerseys.com)
Atlanta Falcons(www.wtojerseys.com)
Baltimore Ravens(www.wtojerseys.com)
Buffalo Bills(www.wtojerseys.com)
Carolina Panthers(www.wtojerseys.com)
Chicago Bears(www.wtojerseys.com)
Cincinnati Bengals(www.wtojerseys.com)
Cleveland Browns(www.wtojerseys.com)
Dallas Cowboys(www.wtojerseys.com)
Denver Broncos(www.wtojerseys.com)
Detroit Lions(www.wtojerseys.com)
Green Bay Packers(www.wtojerseys.com)
Houston Texans(www.wtojerseys.com)
Indianapolis Colts(www.wtojerseys.com)
Jacksonville Jaguars(www.wtojerseys.com)
Kansas City Chiefs(www.wtojerseys.com)
Miami Dolphins(www.wtojerseys.com)
Minnesota Vikings(www.wtojerseys.com)
New England Patriots(www.wtojerseys.com)
New Orleans Saints(www.wtojerseys.com)
New York Giants(www.wtojerseys.com)
San Francisco 49ers(www.wtojerseys.com)
Seattle Seahawks(www.wtojerseys.com)
St. Louis Rams(www.wtojerseys.com)
Tampa Bay Buccaneers(www.wtojerseys.com)
Tennessee Titans(www.wtojerseys.com)
Washington Redskins(www.wtojerseys.com)
New York Jets(www.wtojerseys.com)
Oakland Raiders(www.wtojerseys.com)
Philadelphia Eagles(www.wtojerseys.com)
Pittsburgh Steelers(www.wtojerseys.com)
San Diego Chargers(www.wtojerseys.com)

==============================================================================
TOPIC: Need to use "volatile" for accessing variables between threads?
http://groups.google.com/group/comp.lang.c++/t/4e68d5b929c344d4?hl=en
==============================================================================

== 1 of 3 ==
Date: Mon, Jul 27 2009 10:44 am
From: Greg Herlihy


On Jul 27, 6:51 am, "Alf P. Steinbach" <al...@start.no> wrote:
> * Virchanza:
>
> > Volatile is intended to be used where a variable's value can
> > mysteriously change outside of the normal flow of code.
>
> > I'm still not sure whether "a separate thread" qualifies as being
> > mysterious enough. Some people are telling me I need volatile. Others
> > are telling me I don't need volatile. I don't know who to believe.
>
> > Is it even possible to get an answer to this question, or is it simply
> > "undefined"?
>
> It was answered definitively here:
> <url:http://www.google.com/search?q=alexandrescu+meyers+volatile>

Presumably, you mean that the Meyers & Alexandrescu paper on double-
checked locking:

http://www.aristeia.com/Papers/DDJ_Jul_Aug_2004_revised.pdf

provides a definitive answer.

And it does. The paper concludes that "volatile" is needed in order to
ensure thread-safety - and in fact is needed more than once:

"Our earlier analysis shows that pInstance needs to be declared
'volatile',
and in fact this point is made in the papers on DCLP. However,
Sherlock Holmes would certainly notice that, in order to ensure
correct instruction order, the Singleton object -itself- must be also
'volatile'. This is not noted in the original DCLP papers, and that's
an important oversight." [pg 7-8].

Greg


== 2 of 3 ==
Date: Mon, Jul 27 2009 10:58 am
From: "Bo Persson"


Greg Herlihy wrote:
> On Jul 27, 6:37 am, Richard Herring <junk@[127.0.0.1]> wrote:

>> 3. Once you have that other mechanism in place, there's no need to
>> use volatile.
>
> Not so. Declaring a variable "volatile" forces the compiler to load
> that variable's value from memory each time that value is needed.
> Otherwise - if there are no apparent write operations to the
> variable within a given block of code - then the compiler is very
> likely to store the variable's value in a register once at the
> beginning of the block; and then use the register-based value in
> subsequent operations as that variable's current value.
>

I agree with Richard here. Once the "other mechanism" is in place,
presumably a mutex involving an OS call, the compiler cannot cache
values across the OS call - unless it first makes sure that the OS is
not using any callbacks previously set, that just might affect our
protected variable. Whether it is volatile or not doesn't matter.


Bo Persson


== 3 of 3 ==
Date: Mon, Jul 27 2009 3:00 pm
From: "Alf P. Steinbach"


* Greg Herlihy:
> On Jul 27, 6:51 am, "Alf P. Steinbach" <al...@start.no> wrote:
>> * Virchanza:
>>
>>> Volatile is intended to be used where a variable's value can
>>> mysteriously change outside of the normal flow of code.
>>> I'm still not sure whether "a separate thread" qualifies as being
>>> mysterious enough. Some people are telling me I need volatile. Others
>>> are telling me I don't need volatile. I don't know who to believe.
>>> Is it even possible to get an answer to this question, or is it simply
>>> "undefined"?
>> It was answered definitively here:
>> <url:http://www.google.com/search?q=alexandrescu+meyers+volatile>
>
> Presumably, you mean that the Meyers & Alexandrescu paper on double-
> checked locking:
>
> http://www.aristeia.com/Papers/DDJ_Jul_Aug_2004_revised.pdf
>
> provides a definitive answer.
>
> And it does. The paper concludes that "volatile" is needed in order to
> ensure thread-safety - and in fact is needed more than once:
>
> "Our earlier analysis shows that pInstance needs to be declared
> 'volatile',
> and in fact this point is made in the papers on DCLP. However,
> Sherlock Holmes would certainly notice that, in order to ensure
> correct instruction order, the Singleton object -itself- must be also
> 'volatile'. This is not noted in the original DCLP papers, and that's
> an important oversight." [pg 7-8].

You might read on... ;-)


Cheers & hth.,

- Alf

==============================================================================
TOPIC: Wow, This Is So Sad...
http://groups.google.com/group/comp.lang.c++/t/c6f3bb73a9d27bc1?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Jul 27 2009 11:18 am
From: JustBoo


Default User wrote:
> Juha Nieminen wrote:
>
>> Default User wrote:
>
>>> Irrelevant, as there's very little that can be done about it. And
>>> there's really only one, that's Google Groups. They care little, and
>>> there really isn't anyone who can make them care.
>> If it was some hacked server in some country which couldn't care
>> less about such things, then that would be true. But Google is a huge
>> international company with strict policies. One would think that they
>> can be made to do something about the problem.
>
> Oh? Who will make them if they don't want to be made to care?
>
> This is a serious question. What entity or group of entities would
> really want to take on this 900 lb. gorilla over usenet? If anyone
> would, why haven't we seen it?

Could these guys do something? The Internet Engineering Task Force
(IETF). http://www.ietf.org/

Perhaps through the "RFC process"? Some kind of rule or procedure
performed at the server level? So, just as everyone followed TCP/IP,
"they" would follow the new RFC?

Realize, I am just making a suggestion, not demanding a New World Order. :-)

==============================================================================
TOPIC: How to write previous element in STL list
http://groups.google.com/group/comp.lang.c++/t/2d136691c93121bf?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Jul 27 2009 11:16 am
From: Rolf Magnus


cornelis van der bent wrote:

> On 27 jul, 17:42, Victor Bazarov <v.Abaza...@comAcast.net> wrote:
>> cornelis van der bent wrote:
>>
>> > In my code I want to go through all combinations of two items in a
>> > list. Here is my code:
>>
>> > list<Instance*>::iterator i;
>> > for (i = instances.begin(); i != --instances.end(); i++)
>> > {
>> > list<Instance*>::iterator j;
>> > for (j = i + 1; j < instances.end(); j++)
>> > {
>> > // Do something!
>> > }
>> > }
>>
>> > I get a big error message at i + 1.
>>
>> Such an operation is only defined for random-access iterators, and the
>> list iterator isn't one.
>
> Do you know reason(s) why this has nog been implemented for a list?
> The list is doubly-linked, so giving back an iterator one postion
> earlier/further does not seem to be a big deal.

One position not, that's why there are increment/decrement operators, but
you cannot define addition/subtraction operators that only work with the
value 1. They would have to be usable with any value, and adding e.g. a
million to such an iterator (provied that the list has that many elements
elements) would be possible, but very slow.

==============================================================================
TOPIC: "Concepts" were removed from C++0x
http://groups.google.com/group/comp.lang.c++/t/2a650fa1f3c8016a?hl=en
==============================================================================

== 1 of 4 ==
Date: Mon, Jul 27 2009 10:34 am
From: Rui Maciel


Ioannis Vranos wrote:

> I think after C++1x, focus should be probably given to functional
> programming paradigm.

If someone wants develop using the functional programming paradigm then why shouldn't that person simply pick
up a functional programming language? I mean, where exactly is there a need to bolt on yet another feature to
an already highly complex programming language?


Rui Maciel


== 2 of 4 ==
Date: Mon, Jul 27 2009 11:53 am
From: Brian Wood


On Jul 27, 11:27 am, Rui Maciel <rui.mac...@gmail.com> wrote:
> Brian Wood wrote:
> > "Every new proposal seems neat and promising at first but after
> > a few iterations and redesigns, it might easily turn into a
> > bloated tumor that impedes the natural growth and evolution of
> > the language (namespaces anyone?).
>
> Do namespaces present any problem? IMVHO they are one of C++'s most useful features.
>

Namespaces established a "let's agree to disagree" mentality.
I promote using a website to manage the assignment of names.
Using the internet I think it's possible to improve on the
status quo in this area.


Brian Wood
Ebenezer Enterprises
www.webEbenezer.net


== 3 of 4 ==
Date: Mon, Jul 27 2009 12:27 pm
From: Ioannis Vranos


Rui Maciel wrote:
> Ioannis Vranos wrote:
>
>> I think after C++1x, focus should be probably given to functional
>> programming paradigm.
>
> If someone wants develop using the functional programming paradigm then why shouldn't that person simply pick
> up a functional programming language? I mean, where exactly is there a need to bolt on yet another feature to
> an already highly complex programming language?


AFAIK, the Functional programming paradigm is *probably* a good approach (it makes it easy) for writing
multithreading programs without thread-sharing.

If it is proven to be an efficient approach, I see no reason why C++ should remain behind and do not adopt it.


But it is really soon for such a discussion.


--
Ioannis A. Vranos

C95 / C++03 Developer

http://www.cpp-software.net


== 4 of 4 ==
Date: Mon, Jul 27 2009 2:23 pm
From: Rui Maciel


Ioannis Vranos wrote:

> AFAIK, the Functional programming paradigm is probably a good approach (it
> makes it easy) for writing multithreading programs without thread-sharing.

Yes, and it may even have the potential of simplifying some mundane, frequent programming tasks. Yet, that
doesn't mean that all programming languages should support it.


> If it is proven to be an efficient approach, I see no reason why C++
> should remain behind and do not adopt it.

That's what I don't get. Why exactly is it a good idea to bolt support for yet another programming paradigm
onto C++? Isn't C++ complex enough as it is? In fact, when there is a need for functional programming,
wouldn't it be better to simply use one of the many functional programming languages to perform the tasks
where functional programming shines?


Rui Maciel

==============================================================================
TOPIC: ┈━═☆ www.fjrjtrade.com Wholesale many brand Stock Sunglass,goggle (
paypal payment) + (free shipping)
http://groups.google.com/group/comp.lang.c++/t/5d5157dfd6b41188?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Jul 27 2009 11:32 am
From: "www.wholesale789.com"

┈━═☆ www.fjrjtrade.com Wholesale many brand Stock Sunglass,goggle
(paypal payment) + (free shipping)

Sunglass:


wholesale ADIDAS Sunglass
http://www.fjrjtrade.com/category-1542-b0-Adidas-Sunglass.html
wholesale ARMANI Sunglass
http://www.fjrjtrade.com/category-1543-b0-Armani-Sunglass.html
wholesale Burberry Sunglass
http://www.fjrjtrade.com/category-1544-b0-Burberry-Sunglass.html
wholesale BVLGARL Sunglass
http://www.fjrjtrade.com/category-1545-b0-Bvlgarl-Sunglass.html
wholesale Cartier Sunglass
http://www.fjrjtrade.com/category-1546-b0-Cartier-Sunglass.html
wholesale CHANEL Sunglass
http://www.fjrjtrade.com/category-1547-b0-Chanel-Sunglass.html
wholesale COACH Sunglass
http://www.fjrjtrade.com/category-1548-b0-Coach-Sunglass.html
wholesale D&G Sunglass
http://www.fjrjtrade.com/category-1549-b0-DG-Sunglass.html
wholesale DIESEL Sunglass
http://www.fjrjtrade.com/category-1550-b0-Diesel-Sunglass.html
wholesale DIOR Sunglass
http://www.fjrjtrade.com/category-1551-b0-Dior-Sunglass.html
wholesale ED Hardy Sunglass
http://www.fjrjtrade.com/category-1552-b0-ED-Sunglass.html
wholesale FENDI Sunglass
http://www.fjrjtrade.com/category-1553-b0-Feidi-Sunglass.html
wholesale Ferragamo Sunglass
wholesale GIVENCHY Sunglass
wholesale GUCCI Sunglass
http://www.fjrjtrade.com/category-1554-b0-Gucci-Sunglass.html
wholesale LV Sunglass
http://www.fjrjtrade.com/category-1555-b0-LV-Sunglass.html
wholesale NIKE Sunglass
http://www.fjrjtrade.com/category-1556-b0-Nike-Sunglass.html
wholesale Oakley Sunglass
http://www.fjrjtrade.com/category-1557-b0-Okely-Sunglass.html
wholesale POLICE Sunglass
http://www.fjrjtrade.com/category-1558-b0-Police-Sunglass.html
wholesale PRADA Sunglass
http://www.fjrjtrade.com/category-1559-b0-Prada-Sunglass.html
wholesale Ray.Ban Sunglass
http://www.fjrjtrade.com/category-1560-b0-Rayban-Sunglass.html
wholesale ROBERTO CAVALLI Sunglass
http://www.fjrjtrade.com/category-1636-b0-ROBERTO-CAVALLI-Sunglass.html
wholesale Salvatore Sunglass
http://www.fjrjtrade.com/category-1562-b0-Salvatore-Sunglass.html
wholesale VERSACE Sunglass
http://www.fjrjtrade.com/category-1564-b0-Versace-Sunglass.html
wholesale YSL Sunglass
http://www.fjrjtrade.com/category-1637-b0-YSL-Sunglass.html


goggle:


wholesale Armani goggle
http://www.fjrjtrade.com/category-1497-b0-Armani-goggle.html
wholesale Catier goggle
http://www.fjrjtrade.com/category-1498-b0-Cartier-goggle.html
wholesale Chanel goggle
http://www.fjrjtrade.com/category-1499-b0-Chanel-goggle.html
wholesale D&G goggle
http://www.fjrjtrade.com/category-1500-b0-DG-goggle.html
wholesale DIOR goggle
http://www.fjrjtrade.com/category-1501-b0-Dior-goggle.html
wholesale FENDI goggle
http://www.fjrjtrade.com/category-1502-b0-Fendi-goggle.html
wholesale FERRE goggle
wholesale FRED goggle
http://www.fjrjtrade.com/category-1504-b0-Fred-goggle.html
wholesale GUCCI goggle
http://www.fjrjtrade.com/category-1505-b0-Gucci-goggle.html
wholesale LV goggle
http://www.fjrjtrade.com/category-1506-b0-LV-goggle.html
wholesale MONT BLANC goggle
http://www.fjrjtrade.com/category-1507-b0-Mont-Blanc-goggle.html
wholesale NIKE goggle
http://www.fjrjtrade.com/category-1508-b0-Nike-goggle.html
wholesale Oakley goggle
http://www.fjrjtrade.com/category-1509-b0-Okley-goggle.html
wholesale POLICE goggle
http://www.fjrjtrade.com/category-1510-b0-Police-goggle.html
wholesale PRADA goggle
http://www.fjrjtrade.com/category-1511-b0-Prada-goggle.html
wholesale PUMA goggle
http://www.fjrjtrade.com/category-1512-b0-Puma-goggle.html
wholesale RAY.BAN goggle
http://www.fjrjtrade.com/category-1513-b0-Rayban-goggle.html
wholesale VERSACE goggle
http://www.fjrjtrade.com/category-1514-b0-Versace-goggle.html


Website:
http://www.fjrjtrade.com


==============================================================================
TOPIC: passing by reference
http://groups.google.com/group/comp.lang.c++/t/44dae30d52f6c6db?hl=en
==============================================================================

== 1 of 5 ==
Date: Mon, Jul 27 2009 11:34 am
From: red floyd


On Jul 27, 11:27 am, squid <jvstew...@gmail.com> wrote:

Oh. My. Goodness. There is so much wrong here, I don't know where to
start.

I guess first, you should post in comp.lang.c, as you are coding in
the strict C subset.

> I am trying to pass a pointer to a function and in the function
> allocate some memory for it using malloc

Do not use malloc in a C++ program. Use new.

> and then using it in the
> calling function.  If I return the pointer in the function return
> value and assign it to a pointer variable when I call the function it
> works.
>  But when I try to use the pointer I sent as a parameter it
> says the pointer variable is undefined and I am unable to access the
> allocated memory.

What book are you using that doesn't discuss the fact that C++ uses
pass-by-value?

>
> #include <stdio.h>
> #include <stdlib.h>
>
> char * getbuff(char *);
>
> void main(void)
In C++, main returns int. Period.

> {
> char *a, *b;
>
> b = getbuff(a*);
Won't compile. Bad syntax.
>
> return;
>
> }
>
> char * getbuff(char * p)
> {
>         char * buff;
>         buff = (char *) malloc(sizeof(char) * 8);
>         p = buff;
>     return buff;
>
> }


== 2 of 5 ==
Date: Mon, Jul 27 2009 12:41 pm
From: "Default User"


squid wrote:

> I have to use C for this program. I am using "The Complete Reference"
> Osborne

Then you are in the wrong newsgroup. You want comp.lang.c

By the way, your thread title is incorrect. You are not passing the
pointer by reference (of any sort). C has no reference mechanism, you
have to use a pointer to pointer. C++ does, but you aren't using it.

Brian


== 3 of 5 ==
Date: Mon, Jul 27 2009 1:34 pm
From: red floyd


On Jul 27, 12:41 pm, "Default User" <defaultuse...@yahoo.com> wrote:
> squid wrote:
> > I have to use C for this program.  I am using "The Complete Reference"
> > Osborne
>
> Then you are in the wrong newsgroup. You want comp.lang.c
>
> By the way, your thread title is incorrect. You are not passing the
> pointer by reference (of any sort). C has no reference mechanism, you
> have to use a pointer to pointer. C++ does, but you aren't using it.
>
> Brian

OP deleted his post, and reposted in c.l.c.


== 4 of 5 ==
Date: Mon, Jul 27 2009 1:35 pm
From: "Bo Persson"


squid wrote:
> On Jul 27, 2:49 pm, squid <jvstew...@gmail.com> wrote:
>> On Jul 27, 2:43 pm, squid <jvstew...@gmail.com> wrote:
>>
>>
>>
>>> On Jul 27, 2:34 pm, red floyd <redfl...@gmail.com> wrote:
>>
>>>> On Jul 27, 11:27 am, squid <jvstew...@gmail.com> wrote:
>>
>>>> Oh. My. Goodness. There is so much wrong here, I don't know
>>>> where to start.
>>
>>>> I guess first, you should post in comp.lang.c, as you are coding
>>>> in the strict C subset.
>>
>>>>> I am trying to pass a pointer to a function and in the function
>>>>> allocate some memory for it using malloc
>>
>>>> Do not use malloc in a C++ program. Use new.
>>
>>>>> and then using it in the
>>>>> calling function. If I return the pointer in the function return
>>>>> value and assign it to a pointer variable when I call the
>>>>> function it works.
>>>>> But when I try to use the pointer I sent as a parameter it
>>>>> says the pointer variable is undefined and I am unable to
>>>>> access the allocated memory.
>>
>>>> What book are you using that doesn't discuss the fact that C++
>>>> uses pass-by-value?
>>
>>>>> #include <stdio.h>
>>>>> #include <stdlib.h>
>>
>>>>> char * getbuff(char *);
>>
>>>>> void main(void)
>>
>>>> In C++, main returns int. Period.
>>
>>>>> {
>>>>> char *a, *b;
>>
>>>>> b = getbuff(a*);
>>
>>>> Won't compile. Bad syntax.
>>
>>>>> return;
>>
>>>>> }
>>
>>>>> char * getbuff(char * p)
>>>>> {
>>>>> char * buff;
>>>>> buff = (char *) malloc(sizeof(char) * 8);
>>>>> p = buff;
>>>>> return buff;
>>
>>>>> }
>>
>>> I have to use C for this program. I am using "The Complete
>>> Reference" Osborne
>>
>>> The program compiles in Visual Studio C++ Express Edition.
>>
>> Except for b = getbuff(a*);
>> that was a typo when I made my post it should be
>> b = getbuff(a);
>
> Also I had to initialize the variables so the program is as follows
> and comiples and runs fine on MS ++ Express Edition.
>
>
> #include <stdio.h>
> #include <stdlib.h>
>
>
> char * getbuff(char *);
>
>
> void main(void)
> {
> char *a, *b;
> a = 0, b = 0;
> b = getbuff(a);
>
> return;
> }
>
>
> char * getbuff(char * p)
> {
> char * buff;
> buff = (char *) malloc(sizeof(char) * 8);
> p = buff;

This assigns buff to p, not to a. To have a pointer to a, you would
need getbuff(char** p) which works, but is a lot of trouble.


> return buff;
> }


Why don't you just try

char* getbuff(void);

int main()
{

char* b = getbuff();

}


Bo Persson


== 5 of 5 ==
Date: Mon, Jul 27 2009 2:11 pm
From: "Default User"


red floyd wrote:

> On Jul 27, 12:41 pm, "Default User" <defaultuse...@yahoo.com> wrote:
> > squid wrote:
> > > I have to use C for this program.  I am using "The Complete
> > > Reference" Osborne
> >
> > Then you are in the wrong newsgroup. You want comp.lang.c
> >
> > By the way, your thread title is incorrect. You are not passing the
> > pointer by reference (of any sort). C has no reference mechanism,
> > you have to use a pointer to pointer. C++ does, but you aren't
> > using it.

> OP deleted his post, and reposted in c.l.c.

I saw the later post to clc. "Deleting" posts is something at best
works partially. Many servers ignore all cancel requests, so you tend
to end up with a situation where some people see it and some don't. Not
to mention that it doesn't matter once others have seen it and replied.
It's not like the OP can remove the thread.

In general, it's better to post a reply that indicates the shift to a
new group.


Brian

==============================================================================
TOPIC: The recession and you: has the economy changed your IT spending?
http://groups.google.com/group/comp.lang.c++/t/1c7bb5179e756029?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Jul 27 2009 2:05 pm
From: Mikhail


If you can spare about 10 minutes to take a survey I would love to
hear about how the global recession is (or is not) changing your
personal or organizational IT plans.

http://www.surveymonkey.com/s.aspx?sm=Co3CDMHC47_2fTCyYvGNSa_2fA_3d_3d&c=46

This is part of a study I am conducting for my own blog
(www.surkan.com), and I will be making the results freely available in
the coming weeks. I am doing this as part of my own private research
effort, and it isn't being done on the behalf of any corporations or
clients. This subject (i.e. how the economy impacts IT trends) is
something that has fascinated me for years while I was employed as a
market researcher at Microsoft, and now that I am no longer with the
firm I am free to really explore the subject.

I don't have any fancy prizes, or incentives, to offer you for taking
the survey (i.e. I don't have any kind of research budget), but I can
promise the reward that comes from helping your fellow man, and making
the world a better place.

Ok, that's a little over the top… But your contribution (through
answering the survey questions) will go towards helping the tech
industry understand how to better meet your needs in a changed world.
If nothing else, the results of this study should prove to be an
interesting read for anyone. :)

Thanks,
Michael Surkan

P.S. This survey is designed so that people who say they have an IT
related job will be shown enterprise-type questions. Everyone else
will see questions about technology spending in the home. You are free
to take the survey twice if you are particularly ambitious, answering
both the enterprise and consumer IT sections.

==============================================================================
TOPIC: How can I use unqualified names? (Possibly hard or impossible?)
http://groups.google.com/group/comp.lang.c++/t/e2f24a95fe72b591?hl=en
==============================================================================

== 1 of 2 ==
Date: Mon, Jul 27 2009 2:55 pm
From: Martin Eisenberg


Alf P. Steinbach wrote:

> What Andrei did was to show how all the usual run time control
> structures had analogs in template metaprogramming, and to build
> up from that to a framework handling types just as for run time
> you handle values.

I believe that credit should go to Czarnecki and Eisenecker, whom
MC++D also references.


Martin

--
Quidquid latine scriptum est, altum videtur.


== 2 of 2 ==
Date: Mon, Jul 27 2009 3:23 pm
From: "Alf P. Steinbach"


* Martin Eisenberg:
> Alf P. Steinbach wrote:
>
>> What Andrei did was to show how all the usual run time control
>> structures had analogs in template metaprogramming, and to build
>> up from that to a framework handling types just as for run time
>> you handle values.
>
> I believe that credit should go to Czarnecki and Eisenecker, whom
> MC++D also references.

As I wrote and you snipped, typelists already had some history.

The game of credit (and of snippage) is very silly.

I've never heard of Czarnecki and Eisenecker, and I doubt any reader here will
be helped by that reference. On the other hand, readers might find it useful to
know what Andrei did, in order to decide whether to buy that book. It also
contains a lot of generic implementations of patterns, which perhaps was its
main innovation, and at least a main reason for its popularity, but, due to the
game of credit etc. (uh oh, those wouldn't be /patterns/ anymore, bye GoF!),
goes to pains to point out that patterns cannot be generically implemented. :-)


Cheers & hth.,

- Alf

==============================================================================
TOPIC: dealing with lower level programmers
http://groups.google.com/group/comp.lang.c++/t/f708a2c0cfa8ce2d?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Jul 27 2009 4:37 pm
From: Keith H Duggar


On Jul 27, 11:34 am, Andrew Tomazos <and...@tomazos.com> wrote:
> On Jul 27, 4:03 pm, James Kanze <james.ka...@gmail.com> wrote:
>
> > > I have personally seen a 400k line codebase that was written
> > > largely by one person that was (and maybe its latest versions
> > > still is) used by nearly a million people with minimal
> > > marketing.
>
> > And? A lot of people are using a lot of junk.
>
> The software in question won numerous high profile awards in the face
> of competition, and people described themselves as "huge fans" of it.
> It was noted not only for its nice user interface, but for its amazing
> robustness. It was most certainly good software. Its existence
> disproves your statement.

Why aren't you naming this "software in question"? Are you
hiding something?

KHD


==============================================================================

You received this message because you are subscribed to the Google Groups "comp.lang.c++"
group.

To post to this group, visit http://groups.google.com/group/comp.lang.c++?hl=en

To unsubscribe from this group, send email to comp.lang.c+++unsubscribe@googlegroups.com

To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c++/subscribe?hl=en

To report abuse, send email explaining the problem to abuse@googlegroups.com

==============================================================================
Google Groups: http://groups.google.com/?hl=en

No comments: