Internet Security and Ethical Hacking

Internet Security and Ethical Hacking

Welcome to the unique confluence of hackers , crackers and security professionals
on the world wide web.
This is your complete resource for internet security and ethical hacking.

Ethical Hacker -: The Ethical Hacker :-
Most people think that hackers are computer criminals. They fail to recognise the fact that criminals and hackers are two totally different things. Media is responsible for this. Hackers in reality are actually good and extremely intelligent people who by using their knowledge in a constructive manner help organisations, companies, goverment, etc. to secure documents and secret information on the internet.


WELCOME TO ALL VISITORS

PLEASE BOOKMARK THIS BLOG FOR DAILY UPDATES. FOR HACKING TIPS GO TO COMPUTER SECTION. FOR MORE INFORMATION CONTACT US .
Your Ad Here

SEARCH FROM HERE

Thursday, November 5, 2009

Modifying temporaries
Temporary objects are created and destroyed all the time in a C++ program. A simple example would be a function that returns by value. A temporary is as good as a const object because it makes little sense (usually) to change a temporary object, which is unnamed and has a very short time span. (Note: A temporary can be bound to a const reference in which case the scope of the temporary is the same as that of the reference.) However, as it turns out, in C++ you can change temporaries ... if they are of class type! You can call non-const member functions on a temporary. This is quite similar to binding a temporary to a non-const reference and changing it. Section 3.10.10 in C++ ISO/IEC 14882:1998 standard clearly mentions this exception. There are at least two practical use of such an exception. One is the "Named Parameter" idiom and the other one is the Move Constructor idiom. In case of the named parameter idiom, the member functions might prefer to return the object by non-const reference instead of a by value. Here is an example:

class X
{
public:
int a;
char b;
X() : a(0), b(0) {}
X setA(int i) { a = i; return *this; } // non-const function
X setB(char c) { b = c; return *this; } // non-const function
};

std::ostream & operator << (std::ostream & o, X const & x)
{
o << x.a << " " << x.b;
return o;
}

X createX() // returns X by value.
{
return X();
}

int main (void)
{
// The following code uses the named parameter idiom.
std::cout << createX().setA(10).setB('Z') << std::endl;
}

No comments:

Post a Comment

ASK YOUR QUESTIONS


Your Name
Your Email Address
Subject
Message
SEND YOUR IDEAS
Image Verification
captcha
Please enter the text from the image:
[ Refresh Image ] [ What's This? ]

 
Home | About Owner | Tutorials | Freebies | About Us | Contact Us

Copyright © 2009 CYBERWORLD |Designed by 13551421 143 Templetemo |Converted to blogger by Dark Master