Click here to Skip to main content
15,912,578 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Structure??? Pin
toxcct1-Sep-06 2:20
toxcct1-Sep-06 2:20 
GeneralRe: Structure??? Pin
toxcct1-Sep-06 1:49
toxcct1-Sep-06 1:49 
QuestionRe: Structure??? Pin
prasad_som31-Aug-06 22:56
prasad_som31-Aug-06 22:56 
GeneralRe: Structure??? Pin
Programm3r31-Aug-06 23:04
Programm3r31-Aug-06 23:04 
QuestionTemplate classes Pin
Waldermort31-Aug-06 22:33
Waldermort31-Aug-06 22:33 
AnswerRe: Template classes Pin
toxcct31-Aug-06 22:40
toxcct31-Aug-06 22:40 
GeneralRe: Template classes Pin
Waldermort31-Aug-06 22:45
Waldermort31-Aug-06 22:45 
GeneralRe: Template classes Pin
Waldermort31-Aug-06 22:53
Waldermort31-Aug-06 22:53 
I tell a lie, it worked for the c'tor and d'tor but not the other members.
This is the header file:
template <class _T> class TCollection {
public:
	TCollection();
	~TCollection();
	_T  at(unsigned int iPos);
	void add(_T T);
	void clear();
	int  size();
	bool empty();
private:
	_T* pData;
	int pCount;
};

And the cpp file looks something like this:
TCollection<class _T>::TCollection() : pData(0) , pCount(0)
{
}

TCollection<class _T>::~TCollection()
{
	clear();
}

_T TCollection<class _T>::at(unsigned int iPos)
{
	if (iPos >= 0 && iPos > pCount)
		return pData[iPos];
	else
		return NULL;
}

void TCollection<class _T>::add(_T T)
{
	if (pData) {
		_T *tmp = new _T [pCount+1];
		for (int i=0;i<pCount;i++)
			tmp[i] = pData[i];
		tmp[i] = T;
		delete [] pData;
		pData = tmp;
		pCount++;
	} else {
		pData = new _T [1];
		pData[0] = T;
		pCount++;
	}
}

I'm getting error like
E:\Program\foo\TCollection.cpp(18) : error C2027: use of undefined type '_T'<br />
        E:\Program\foo\TCollection.cpp(8) : see declaration of '_T'<br />
E:\Program\foo\TCollection.cpp(20) : error C2036: 'class _T *' : unknown size<br />
E:\Program\foo\TCollection.cpp(28) : error C2512: '_T' : no appropriate default constructor available

This is only after a split it into seperate files, it worked in a single file.
GeneralRe: Template classes Pin
toxcct31-Aug-06 22:56
toxcct31-Aug-06 22:56 
GeneralRe: Template classes Pin
Waldermort31-Aug-06 23:06
Waldermort31-Aug-06 23:06 
GeneralRe: Template classes Pin
toxcct31-Aug-06 23:08
toxcct31-Aug-06 23:08 
GeneralRe: Template classes Pin
Waldermort31-Aug-06 23:15
Waldermort31-Aug-06 23:15 
GeneralRe: Template classes Pin
toxcct31-Aug-06 23:19
toxcct31-Aug-06 23:19 
GeneralRe: Template classes Pin
Waldermort31-Aug-06 23:27
Waldermort31-Aug-06 23:27 
GeneralRe: Template classes Pin
Zac Howland1-Sep-06 4:18
Zac Howland1-Sep-06 4:18 
GeneralRe: Template classes Pin
toxcct1-Sep-06 4:47
toxcct1-Sep-06 4:47 
AnswerRe: Template classes Pin
prasad_som31-Aug-06 22:44
prasad_som31-Aug-06 22:44 
AnswerRe: Template classes Pin
Anonymuos1-Sep-06 0:30
Anonymuos1-Sep-06 0:30 
GeneralRe: Template classes Pin
Waldermort1-Sep-06 1:44
Waldermort1-Sep-06 1:44 
AnswerRe: Template classes Pin
MayankT1-Sep-06 0:45
MayankT1-Sep-06 0:45 
GeneralRe: Template classes Pin
toxcct1-Sep-06 1:51
toxcct1-Sep-06 1:51 
AnswerRe: Template classes Pin
Michael Dunn1-Sep-06 5:57
sitebuilderMichael Dunn1-Sep-06 5:57 
QuestionQuestion about dynamically allocated memory Pin
Eikthrynir31-Aug-06 21:37
Eikthrynir31-Aug-06 21:37 
AnswerRe: Question about dynamically allocated memory Pin
Stephen Hewitt31-Aug-06 21:43
Stephen Hewitt31-Aug-06 21:43 
AnswerRe: Question about dynamically allocated memory Pin
prasad_som31-Aug-06 22:21
prasad_som31-Aug-06 22:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.