Image

Imageworldsoutro wrote in Imagecpp

Copy Constructor help

hey


Can anyone help with this copy constructor issue??? I know i can use a shallow copy but my professor wants to see a copy constructor. I'am having problems intializing it and printing it out in main(). Its not very long


#include<iostream>


using namespace std;


class myTest
{
    private:
       
   double num1,num2,num3;
   
    public:
       
        myTest():num1(0), num2(0), num3(0)
        {
        }
       
        myTest(double n1, double n2, double n3): num1(n1), num2(n2),num3(n3)
        {
        }    
 
void myTest::set_myFunctions(double n1, double n2, double n3);

void print();

double multipleNumbers();

void print2();

myTest(const myTest& objectCopy);


};

void myTest::set_myFunctions(double n1, double n2, double n3){
   
 num1 = n1;
 num2 = n2;
 num3 = n3;  
   

void myTest::print(){
   
  cout<<"Here is the numbers "<<num1<<" "<<num2<<" "<<num3<<"\n\n"; 
   
   
}   
double myTest::multipleNumbers()
{
   
     return num1 * num2 * num3;
 } 
 void myTest::print2(){
    
        cout<<"After effects of mulitple "<<multipleNumbers()<<"\n\n\n\n";
       } 
     myTest::myTest
               (const myTest& a)
              
                 {
                     num1 = a.num1;
                     num2 = a.num2;
                     num3 = a.num3;
                   
                      
                     }     
        

int main(){
   
    myTest m1(4,5,7);
   
   
   
    //m1.set_myFunctions;
    m1.print();
    m1.multipleNumbers();
    m1.print2();
   
    //myTest s = a;

   
   
   
   
   
   
    system("PAUSE");
   
    return 0;

 

}  










Any help would be appreciated

Thank you