Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > copy constructor basic

Reply
Thread Tools

copy constructor basic

 
 
kathy
Guest
Posts: n/a
 
      02-16-2011
For class:

class Foo
{
public:
Foo();
Foo(Foo const&)=delete;
Foo& operator =(Foo const&)=delete;
}

What "=delete" means?
 
Reply With Quote
 
 
 
 
Juha Nieminen
Guest
Posts: n/a
 
      02-16-2011
kathy <(E-Mail Removed)> wrote:
> For class:
>
> class Foo
> {
> public:
> Foo();
> Foo(Foo const&)=delete;
> Foo& operator =(Foo const&)=delete;
> }
>
> What "=delete" means?


WIYF.

http://en.wikipedia.org/wiki/C%2B%2B...mber_functions
 
Reply With Quote
 
 
 
 
Saeed Amrollahi
Guest
Posts: n/a
 
      02-16-2011
On Feb 16, 6:32*pm, kathy <(E-Mail Removed)> wrote:
> For class:
>
> class Foo
> {
> public:
> * * Foo();
> * * Foo(Foo const&)=delete;
> * * Foo& operator =(Foo const&)=delete;
>
> }
>
> What "=delete" means?


Hi Kathy

It's new feature of C++0x called deleted functions. For example
in C++03 if you want to prohibit the copy operations, i.e nobody
can't to copy an object or assign to, you have to declare
these special member functions private:
class Foo {
private:
Foo(const Foo&);
Foo& operator=(const Foo&);
};

Now you can say more explicit using delete keyword.
Closely related to deleted functions are defaulted functions.
class Foo {
Foo() = default;
};
It means, you accepted the default behavior of default
constructor which compiler generates for you.
Such thing is somehow more elaboration.

HTH,
-- Saeed Amrollahi
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
template copy constructor vs normal copy constructor cinsk C++ 35 10-10-2010 11:14 PM
A constructor calling another constructor (default constructor)? Generic Usenet Account C++ 10 11-28-2007 04:12 AM
Calling base class constructor from derived class Copy constructor ali C++ 4 03-05-2007 09:15 AM
deep/shallow copy - constructor v Object.copy() VisionSet Java 8 04-29-2004 10:41 PM
Copy constructor hides default constructor Aire C++ 3 01-25-2004 05:47 PM



Advertisments