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

Thread: destructor. friend, and copy constructor

  1. #1
    Join Date
    Mar 2009
    Posts
    13

    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.....

    Code:
    #include<iostream>
    #include<string>
    
    using namespace std;
    
    class Arithmetic
    
    {
    public:
    	int Add(int num1, int num2);
    	int Subtract(int num1, int num2);
    	int Multiply(int num1, int num2);
    
    private:
    	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
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: destructor. friend, and copy constructor

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

  3. #3
    Join Date
    Aug 2008
    Location
    India
    Posts
    186

    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
    Location
    Timisoara, Romania
    Posts
    14,360

    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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center