-
February 15th, 2009, 12:40 PM
#1
New with templates!! pls help
Hello. Iam new in programming and i have a problem with templates class:
#include <iostream>
using namespace std;
template <class T>
class Complex{
T *rp,*ip; // pointers se pragmatiko kai fantastiko meros
public:
T real() const {return *rp;}
T imag() const (return *ip;}
Complex(Tr=0,Ti=0):rp(new T(r)),ip(new T(i)){}
}
I want to write down the destructor of the class, the copy destructor and the assignment operator. Please help!!!
-
February 15th, 2009, 12:45 PM
#2
Re: New with templates!! pls help
I want to write down the destructor of the class, the copy destructor and the assignment operator.
What's the problem ? It's the same as in a class without a template.
-
February 16th, 2009, 02:54 AM
#3
Re: New with templates!! pls help
Why are you using pointers for the real an imaginary part of the complex number? I don't see the point of that.
-
February 16th, 2009, 04:02 AM
#4
Re: New with templates!! pls help
hello..its only for educational purposes. its not a real program. so..the destructor of that class should be like the below?
~Complex(){cout<<"Destructor\n"; delete rp; delete ip;}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|