C++ templates?
C++ templates?
- Subject: C++ templates?
- From: "David Piasecki" <email@hidden>
- Date: Thu, 15 Apr 2004 11:04:15 -0700
I tried creating a C++ template for my Cocoa application in XCode. It
compiles fine, but I get a runtime error which crashes my application,
even if all I do is create the object. Source included below...
David
#include "MyMath.h"
class MyObject {
public:
MyObject();
~MyObject();
MyMath<int> mathUtility; // this line causes the app to crash
private:
};
-----------------------------------------------
template <class T>
class MyMath {
public:
MyMath();
~MyMath();
T max( T a, T b );
T min( T a, T b );
private:
};
--------------------------------------------------
#include "MyMath.h"
template <class T>
MyMath<T>::MyMath() { }
template <class T>
MyMath<T>::~MyMath() { }
template <class T>
T MyMath<T>::max( T a, T b ) {
if( a > b ) return a;
else return b;
}
template <class T>
T MyMath<T>::min( T a, T b ) {
if( a < b ) return a;
else return b;
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.