troubleshooting Question

How to copy a class object....please take a look

Avatar of Thomas Stockbruegger
Thomas StockbrueggerFlag for Germany asked on
Visual C++.NET
6 Comments1 Solution263 ViewsLast Modified:
Hello,
I am a beginner in Visual C++.Net. I need some help with my class.

I would like to copy one object to another one.

Here is the code:
//------------------- Test.h -------------------------------------
Class Test
{
    public:
    double AN, double BN, double CN;

    // Constructor
    Test(double a, double b, double c);

   // Destructor
    ~Test();

   //Function
   void Just_a_test();

};
//------------------- Test.cpp -------------------------------------
# include "Test.h";

Test::Test(double a, double b, double c)
{
    AN=a;
    BN=b;
    CN=c;
}

Test::~Test()
{
}

// Function
 void Just_a_test()
{
    ...just do something with AN, BN and CN
}

//----------------------------- my Dlg.cpp --------------------------------
.... on click button i.e.

double a,b,c;

a=100;
b=200;
c=300;
// create a object and call constructor
Test First_Object (a,b,c);

// call the function
First_Object.Just_a_test();

****************************************
I would like to create now a new object i.e. Second_Object and copy all the data from
First_Object

Back in c++ I just did this:
Second_Object=First_Object;

This will not work with Visual c++
Please let me know.
Please give me some credit .... I am a beginner.

Thank you
With best regards,
Thomas





ASKER CERTIFIED SOLUTION
AlexFM

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros