destructor. friend, and copy constructor
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 4 of 4

Thread: destructor. friend, and copy constructor

  1. #1
    Join Date
    Mar 2009

    destructor. friend, and copy constructor

    I am working on a program and need to make a friend, deconstructor, and copy constructor.....

    I was given this formula for the destructor and completely confused...

    cout << value1 << value2

    I also do not seem to see a whole lot of information on copy constructors and friends so was wanting to know if someone can help me in exactly what I have to do for these.....

    using namespace std;
    class Arithmetic
    	int Add(int num1, int num2);
    	int Subtract(int num1, int num2);
    	int Multiply(int num1, int num2);
    	int addedTotal, subtractedTotal, multipliedTotal;
    //Adding the two numbers together
    int Add(int num1, int num2)
    	int addedTotal;
    	addedTotal = num1 + num2;
    	cout << endl << "The two numbers added together are: " << addedTotal;
    	return addedTotal;
    //Subtracting the two numbers together
    int Subtract(int num1, int num2)
    	int subtractedTotal;
    	subtractedTotal = num1 - num2;
    	cout << endl << endl << "Subtracting the first and second number give a difference of: " << subtractedTotal << endl ;
    	return subtractedTotal;
    //Multiplying the two numbers together
    int Multiply(int num1, int num2)
    	int multipliedTotal;
    	multipliedTotal = num1 * num2;
    	cout << endl << "Numbers 1 and 2 multiplied together give a product of: " << multipliedTotal << endl << endl;
    	return multipliedTotal;
    int main()
    	int num1, num2;
    	cout << "Enter the first number: ";
    	cin >> num1;
    	cout << endl << "Enter the second number: ";
    	cin >> num2;
    	Add(num1, num2);
    	Subtract(num1, num2);
    	Multiply(num1, num2);

  2. #2
    Join Date
    Sep 2004
    Holland (land of the dope)

    Re: destructor. friend, and copy constructor

    cout << value1 << value2
    This has nothing to do with a destructor.

  3. #3
    Join Date
    Aug 2008

    Re: destructor. friend, and copy constructor

    I am not getting your code.... what are you trying to do here....
    You have declared the function in a class definition but defined it globally without class reference...

    Also there is no class object created in main() to access these functions.... !!!

  4. #4
    Join Date
    Oct 2002
    Timisoara, Romania

    Re: destructor. friend, and copy constructor

    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a survey!

HTML5 Development Center