Hello,
As we can see the compiler complains about the class
definition in the *.cpp file.
> \myFolder\myClass.cpp In constructor
> `myClass<Type>::myClass(const Type&)':
>
> 7 \myFolder\myClass.cpp syntax error before `;'
> token
> \myFolder\Makefile.win [Build Error] [myClass.o]
> Error 1
And, the complaint is about the way you have created a
new myClass object. Firtsly, you have declared a
protected member object of type Type in the class
declaration and not a pointer to an object of type
Type. So I guess the declaration code should be
changed to:
Type* count; // Declare count as a pointer.
Next, even after making such a correction, the way you
should go about initialising this object is:
count = new Type(item);
and not as:
count = new Type item;
Even here, the class of type Type should have a
logically correct copy constructor.
> Lastly, here is my myClass.cpp code:
> _____________________
> #include <iostream>
> #include "myClass.h"
>
> template<class Type>
> myClass<Type>::myClass(const Type &item) //default
> constructor
> {
> count = new Type item;
> }
Hope this helps,
Siva Chandra
__________________________________
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
http://promotions.yahoo.com/new_mail
|