http://groups.google.com/group/comp.lang.c++?hl=en
comp.lang.c++@googlegroups.com
Today's topics:
* "Reusable" operator overloading for enum? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/981ab2c7a0c2c5ff?hl=en
* Saving a binary file into a string - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/ddc89ddf30293133?hl=en
* ☻☀☻☀☻Wholesale cheap Nike AirMax shoes at www.ecyaya.com 【paypal payment】 -
1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/ee7c8cee2a2bb776?hl=en
* ◆@◆@◆ 2009 Prada shoes Cheap Wholesale at website www.fjrjtrade.com <paypal
payment> - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/6f01719e5e78c2d7?hl=en
* Gigantic Class - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/b3756783d92fd56a?hl=en
==============================================================================
TOPIC: "Reusable" operator overloading for enum?
http://groups.google.com/group/comp.lang.c++/t/981ab2c7a0c2c5ff?hl=en
==============================================================================
== 1 of 1 ==
Date: Sun, Dec 27 2009 9:53 pm
From: nick
Thanks, Balog. I did away with the ~ operator, but instead of
replacing it with a named function I figured I'd use the - and -=
operators for unsetting the flag. Here's what I ended up with, maybe
this will be useful for someone else.
#define FLAGS_(T) \
inline static T operator*(bool l, T r) \
{ return (T)(l*(unsigned)r); } \
inline static T operator*(T l, bool r) \
{ return (T)((unsigned)l*r); } \
inline static T operator|(T l, T r) \
{ return (T)((unsigned)l|r); } \
inline static T operator&(T l, T r) \
{ return (T)((unsigned)l&r); } \
inline static T operator+(T l, T r) \
{ return l|r; } \
inline static T operator-(T l, T r) \
{ return l&r?(T)((unsigned)l-(unsigned)r):l; } \
inline static T& operator|=(T& l, T r) \
{ return l = l|r; } \
inline static T& operator&=(T& l, T r) \
{ return l = l&r; } \
inline static T& operator+=(T& l, T r) \
{ return l = l+r; } \
inline static T& operator-=(T& l, T r) \
{ return l = l-r; }
==============================================================================
TOPIC: Saving a binary file into a string
http://groups.google.com/group/comp.lang.c++/t/ddc89ddf30293133?hl=en
==============================================================================
== 1 of 2 ==
Date: Sun, Dec 27 2009 10:07 pm
From: Kaz Kylheku
On 2009-12-27, Jorgen Grahn <grahn+nntp@snipabacken.se> wrote:
> On Sun, 2009-12-27, Dominik Schmidt wrote:
>> Hi,
>>
>> I'm new to C++, so I have a very basic question.
>> I wrote a function which opens a file and saves it into a string variable.
>> Another function can save a string variable into a file.
>
> ...
>> void SaveFile(string FilePath, string FileContent)
>
> You should learn to use references; that's better written as
>
> void SaveFile(const string& path, const string& s)
Under any sanely implemented compiler, there is no difference.
So this is like writing x >> 2 instead of x / 2.
The caller passes pointers to the objects; the callee will make copy
if it modifies the arguments, otherwise it works with the caller's
objects directly.
> Having to fit the whole file in memory *once* is problematic enough;
> here you double the memory needed.
Even if the compiler is stupid to actually copy the objects in argument
passing, the implementation of std::string can prevent copying the
actual data by managing references.
== 2 of 2 ==
Date: Sun, Dec 27 2009 10:31 pm
From: Joshua Maurice
On Dec 28, 1:07 am, Kaz Kylheku <kkylh...@gmail.com> wrote:
> void SaveFile(string FilePath, string FileContent)
> void SaveFile(const string& path, const string& s)
>
> Under any sanely implemented compiler, there is no difference.
>
> So this is like writing x >> 2 instead of x / 2.
>
> The caller passes pointers to the objects; the callee will make copy
> if it modifies the arguments, otherwise it works with the caller's
> objects directly.
Really? This surprises me, considering this is the first I've heard
about such magics, and many longtime posters here seem to assume /
know otherwise. Division by two vs bitshifting is very simply,
provably equivalent code, but changing a pass by value to a pass by
const ref is much more involved, and I believe the analogy does not
work.
So, how would this be implemented and still have a separate
compilation model?
Ex:
//
#include <iostream>
using namespace std;
class foo
{
public:
foo() { cout << "foo()" << endl; }
foo(const foo& ) { cout << "foo(const foo& )" << endl; }
foo& operator= (const foo& ) { cout << "foo& operator= (const foo& )"
<< endl; return *this; }
~foo() { cout << "~foo()" << endl; }
};
void passByValue(foo ) {}
int main()
{
foo x;
passByValue(x);
}
//
I think that this example must have exactly one ctor call, one copy
ctor call, and 2 dtor calls. I don't see how you can change it and
still have it be standard compliant.
On a more general program, barring whole program optimization with the
standard's "as if" rule, that is still with separate compilation, I
don't see how you can do it.
> Even if the compiler is stupid to actually copy the objects in argument
> passing, the implementation of std::string can prevent copying the
> actual data by managing references.
Except it might not do copy on write strings because that can be more
expensive for certain applications. That's a tradeoff optimization,
not a globally better one.
==============================================================================
TOPIC: ☻☀☻☀☻Wholesale cheap Nike AirMax shoes at www.ecyaya.com 【paypal
payment】
http://groups.google.com/group/comp.lang.c++/t/ee7c8cee2a2bb776?hl=en
==============================================================================
== 1 of 1 ==
Date: Mon, Dec 28 2009 12:27 am
From: hero
☻☀☻☀☻Wholesale cheap Nike AirMax shoes at www.ecyaya.com 【paypal
payment】
AirMax 87 at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-461-b0-Nike-Air-Max-87.html
AirMax 87 (M&W) at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-466-b0-Nike-Air-Max-87-MW.html
AirMax 87(M) at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-464-b0-Nike-Air-Max-87-Man.html
AirMax 87(W) at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-465-b0-Nike-Air-Max-87-Women.html
AirMax 89 at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-467-b0-Nike-Air-Max-89.html
AirMax 90 at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-468-b0-Nike-Air-Max-90.html
AirMax 90 Current Man at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-469-b0-Nike-Air-Max-90-Current-Man.html
AirMax 90(M) at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-470-b0-Nike-Air-Max-90-Man.html
AirMax 90(W) at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-471-b0-Nike-Air-Max-90-Women.html
AirMax 90 Man Hight at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-472-b0-Nike-Air-Max-90-Man-Hight.html
AirMax 90 Kid at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-520-b0-Nike-Air-Max-90-Kid.html
AirMax 91 at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-474-b0-Nike-Air-Max-91.html
AirMax 91 Man at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-475-b0-Nike-Air-Max-91-Man.html
AirMax 91 Woman at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-476-b0-Nike-Air-Max-91-Women.html
AirMax92 at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-477-b0-Nike-Air-Max-92.html
AirMax 93 at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-478-b0-Nike-Air-Max-93.html
AirMax 95 at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-479-b0-Nike-Air-Max-95.html
AirMax 95 Man at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-480-b0-Nike-Air-Max-95-Man.html
AirMax 95 Woman at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-481-b0-Nike-Air-Max-95-Women.html
AirMax 95 Kid at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-521-b0-Nike-Air-Max-95-Kid.html
AirMax 97 at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-483-b0-Nike-Air-Max-97.html
AirMax 97 Man at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-484-b0-Nike-Air-Max-97-Man.html
AirMax 97 Woman at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-485-b0-Nike-Air-Max-97-Women.html
AirMax 180 at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-486-b0-Nike-Air-Max-180.html
AirMax 2006 at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-487-b0-Nike-Air-Max-2006.html
AirMax 2006 1era man at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-488-b0-Nike-Air-Max-2006-1era-Man.html
AirMax 2006 1era Woman at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-489-b0-Nike-Air-Max-2006-1era-Women.html
AirMax 2006 1era M&W at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-490-b0-Nike-Air-Max-2006-1era-MW.html
AirMax 2006 2era man at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-491-b0-Nike-Air-Max-2006-Man-2era.html
AirMax 2006 3era man at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-492-b0-Nike-Air-Max-2006-3era-Man.html
AirMax 2006 3era Women at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-493-b0-Nike-Air-Max-2006-3era-Women.html
AirMax 2009 at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-494-b0-Nike-Air-Max-2009.html
AirMax 2009 Man at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-495-b0-Nike-Air-Max-2009-Man.html
AirMax 2009 Women at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-496-b0-Nike-Air-Max-2009-Women.html
AirMax 2009 2era Man at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-1365-b0-Nike-Air-Max-2009-2era-Man.html
AirMax 2009 2era Women at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-1366-b0-Nike-Air-Max-2009-2era-Women.html
AirMax Classic BW at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-497-b0-Nike-Air-Max-Clssic-BW.html
AirMax LTD at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-498-b0-Nike-Air-Max-LTD.html
AirMax LTD Man at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-499-b0-Nike-Air-Max-LTD-Man.html
AirMax LTD Women at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-500-b0-Nike-Air-Max-LTD-Women.html
AirMax LTD Kid at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-522-b0-Nike-Air-Max-LTD-Kid.html
AirMax LTD 2era Man at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-502-b0-Nike-Air-Max-LTD-2era-Man.html
AirMax LTD 2era Women at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-503-b0-Nike-Air-Max-LTD-2era-Women.html
AirMax Skyline at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-504-b0-Nike-Air-Max-Skyline.html
AirMax Skyline Man at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-505-b0-Nike-Air-Max-Skyline-Man.html
AirMax Skyline Women at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-506-b0-Nike-Air-Max-Skyline-Women.html
AirMax STAB at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-507-b0-Nike-Air-Max-STAB.html
AirMax Tailwind at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-508-b0-Nike-Air-Max-Tailwind.html
AirMax TN at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-509-b0-Nike-Air-Max-TN.html
AirMax TN Man at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-510-b0-Nike-Air-Max-TN-Man.html
AirMax TN Women at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-511-b0-Nike-Air-Max-TN-Women.html
AirMax TN Kid at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-523-b0-Nike-Air-Max-TN-Kid.html
AirMax TN8 Man at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-512-b0-Nike-Air-Max-TN8-Man.html ]
AirMax TN8 Women at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-513-b0-Nike-Air-Max-TN8-Women.html
AirMax TN10 Man at www.ecyaya.com 【paypal payment】
http://www.ecyaya.com/category-514-b0-Nike-Air-Max-TN10-Man.html
==============================================================================
TOPIC: ◆@◆@◆ 2009 Prada shoes Cheap Wholesale at website www.fjrjtrade.com <
paypal payment>
http://groups.google.com/group/comp.lang.c++/t/6f01719e5e78c2d7?hl=en
==============================================================================
== 1 of 1 ==
Date: Mon, Dec 28 2009 12:28 am
From: "www.fjrjtrade.com"
◆@◆@◆ 2009 Prada shoes Cheap Wholesale at website www.fjrjtrade.com
<paypal payment>
Welcome to visit www.fjrjtrade.com
cheap wholesale brand shoes www.fjrjtrade.com
cheap wholesale shoes www.fjrjtrade.com
cheap wholesale shoes www.fjrjtrade.com
Men size 40,41,42,43,44,45,46. Women size 36,37,38,39,40.
High quality wholesale Air Force One shoes, Nike Jordan, Nike,Air Max,
Nike Shox, UGG Shoes, Puma Shoes, Nike shoes, Adidas Shoes, Christian
Louboutin, Chanel Shoes, Coach Shoes, D&G Shoes, Dior Shoes, ED Hardy
Shoes, Evisu Shoes, Fendi Shoes, AFF shoes, Bape shoes, Gucci Shoes,
Hogan shoes, Bikkembergs Shoes, Dsquared Shoes, LV Shoes, Timberland
Shoes, Boss shoes, Versace Shoes, Prada Shoes, Lacoste Shoes, Mauri
Shoes, DC shoes ect. Details at website www.fjrjtrade.com
Wholesale Prada Shoes
http://www.fjrjtrade.com/945-Prada-Shoes.html
Wholesale Prada kid's Shoes
http://www.fjrjtrade.com/1616-Prada-Shoes-Kids.html
Wholesale Prada Hight Shoes
http://www.fjrjtrade.com/1124-Prada-Shoes-Hight.html
Wholesale Prada Men Shoes
http://www.fjrjtrade.com/1125-Prada-Shoes-Man.html
Wholesale Prada Women Shoes
http://www.fjrjtrade.com/1126-Prada-Shoes-Woman.html
Website:
http://www.fjrjtrade.com
==============================================================================
TOPIC: Gigantic Class
http://groups.google.com/group/comp.lang.c++/t/b3756783d92fd56a?hl=en
==============================================================================
== 1 of 1 ==
Date: Mon, Dec 28 2009 1:00 am
From: "io_x"
"Immortal Nephi" <Immortal_Nephi@hotmail.com> ha scritto nel messaggio
news:dcc957fe-3558-4f5b-a7a0-4c819a003d52@u1g2000pre.googlegroups.com...
>I consider to use either object-based programming or object-oriental
...
i find the word "private" and "protected" not useful
like the word "const".
in my code where is the problem?
--------------------------------------------
there is someone that in few line of C++ code (that runs)
can show (or better make the debugger show)
the useful of that words?
it seems to understand the word "protected" could be
useful for not make happen wrong operator overloading
or something of that, right?
thanks
--------------------------------------------
#include <iostream>
#include <list>
#include <string>
#include <cstdio>
#define P printf
using namespace std;
class A
{public:
A():a(1),b(2){}
~A(){}
int a;
int b;
};
class B : public A
{public:
B():c(3),d(4){}
~B() {}
int c;
int d;
};
--------------
a=101
b=202
c=303
d=404
e=505
f=606
g=707
h=808
i=900
j=1000
class C : public B
{public:
C():e(5),f(6){}
~C(){}
int e;
int f;
};
class D : public C
{public:
D():g(7),h(8){}
~D() {}
void Run()
{a+=100;
b+=200;
c+=300;
d+=400;
e+=500;
f+=600;
g+=700;
h+=800;
}
int g;
int h;
};
class E : public D
{public:
E():i(9),j(10){}
~E(){}
void Run()
{D::Run();
i = 900;
j = 1000;
}
void print()
{P("a=%d\n", a);
P("b=%d\n", b);
P("c=%d\n", c);
P("d=%d\n", d);
P("e=%d\n", e);
P("f=%d\n", f);
P("g=%d\n", g);
P("h=%d\n", h);
P("i=%d\n", i);
P("j=%d\n", j);
}
int i;
int j;
};
int main()
{E e; // object e is the interface
e.Run(); // Run() is available to client.
e.print();
return 0;
}
==============================================================================
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:
Post a Comment