copy constructor compilation error

Discussion in 'C Programming' started by mnvasanth, Mar 23, 2007.

  1. mnvasanth

    mnvasanth

    Joined:
    Mar 23, 2007
    Messages:
    1
    Hi , please give your comment for compiler error in the following code

    #include <iostream>
    using namespace std;

    class CA
    {
    public:
    CA(int a=0)
    {
    cout<<"in constructor"<<endl;
    }
    ~CA()
    {
    cout<<"in Destructor"<<endl;
    }
    CA(CA&)
    {
    cout<<"in copy"<<endl;
    }

    };

    int main()
    {

    CA a = CA(2);

    }

    The GCC compiler gives the following error

    ../main.cpp: In function `int main()':
    ../main.cpp:27: error: no matching function for call to `CA::CA(CA)'
    ../main.cpp:17: note: candidates are: CA::CA(CA&)
    ../main.cpp:9: note: CA::CA(int)
    mnvasanth, Mar 23, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VisionSet
    Replies:
    8
    Views:
    4,875
    Tris Orendorff
    Apr 29, 2004
  2. Aire
    Replies:
    3
    Views:
    454
    Mike Wahler
    Jan 25, 2004
  3. ali
    Replies:
    4
    Views:
    558
    David Harmon
    Mar 5, 2007
  4. Generic Usenet Account
    Replies:
    10
    Views:
    2,197
    robertwessel2@yahoo.com
    Nov 28, 2007
  5. cinsk
    Replies:
    35
    Views:
    2,559
    James Kanze
    Oct 11, 2010
Loading...

Share This Page