Click here to Skip to main content
15,915,093 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralStandBy Computer Pin
Rajesh_K_Sharma8-Oct-04 0:50
Rajesh_K_Sharma8-Oct-04 0:50 
GeneralRe: StandBy Computer Pin
Blake Miller8-Oct-04 5:03
Blake Miller8-Oct-04 5:03 
QuestionHow to handle Mouse movements on Status Area Icon that i created using Shell_NotifyIcon Pin
Seejoy Jose8-Oct-04 0:44
Seejoy Jose8-Oct-04 0:44 
AnswerRe: How to handle Mouse movements on Status Area Icon that i created using Shell_NotifyIcon Pin
Sujan Christo8-Oct-04 1:02
Sujan Christo8-Oct-04 1:02 
QuestionDebug 'Attach to Process' failing why? Pin
rdhamija8-Oct-04 0:06
rdhamija8-Oct-04 0:06 
AnswerRe: Debug 'Attach to Process' failing why? Pin
Blake Miller8-Oct-04 5:06
Blake Miller8-Oct-04 5:06 
GeneralHelp needed with font Pin
Azghar Hussain7-Oct-04 23:57
professionalAzghar Hussain7-Oct-04 23:57 
GeneralNontype class template partial specialisation Pin
J.B.7-Oct-04 23:56
J.B.7-Oct-04 23:56 
Hi guys,
is it possible to define partial specialisation for a class template that contains nontype parameter? I wrote a simple template example and wanted to do a specialisation for char * type. I couldn't figure out how to do it, any thoughts?

My original template class is below:
template<class kind, int stack_size>
class stack {
	private:
		int count;			// Number of items in the stack
		kind data[stack_size];		// The items themselves
	public:
		// Initialise the stack
		stack (void) {
			count = 0;		// Zero the stack
		}

		// Push an item on the stack
		void push (const kind item);

		// Pop an item from the stack
		kind pop (void) {
			// Stack goes down by one
			--count;
			// Then we return the top value
			return (data[count]);
		}
};

With push() member function separately defined.
template<class kind, int stack_size>
inline void stack<kind, stack_size>::push(const kind item)
{
	data[count] = item;
	++count;
}

Now I tried to specialise the class for char *
template<int stack_size>
class stack<char *, stack_size>
{
	private:
		int count;			// Number of items in the stack
		char *data[stack_size];		// The items themselves
	public:
		// Initialise the stack
		stack (void) {
			count = 0;		// Zero the stack
		}

		// Push an item on the stack
		void push (const char *item);

		// Pop an item from the stack
		char *pop (void) {
			// Stack goes down by one
			--count;
			// Then we return the top value
			return (data[count]);
		}
};
<br>
inline void stack<char *, stack_size>::push(const char *item)      <---- error
{
				data[count] = strdup(item);
				++count;
}

The part above wouldn't compile properly. I got a compile error when it hits the push() function definition. It says the stack_size is undeclared identifier.

Thanks.
GeneralRe: Nontype class template partial specialisation Pin
Joaquín M López Muñoz8-Oct-04 0:52
Joaquín M López Muñoz8-Oct-04 0:52 
GeneralRe: Nontype class template partial specialisation Pin
J.B.8-Oct-04 1:03
J.B.8-Oct-04 1:03 
GeneralRe: Nontype class template partial specialisation Pin
Joaquín M López Muñoz8-Oct-04 2:17
Joaquín M López Muñoz8-Oct-04 2:17 
GeneralSending SMS to any Mobile thru Visual C++ code Pin
Junnybol7-Oct-04 23:37
Junnybol7-Oct-04 23:37 
GeneralRe: Sending SMS to any Mobile thru Visual C++ code Pin
Robert A. T. Káldy8-Oct-04 3:42
Robert A. T. Káldy8-Oct-04 3:42 
GeneralRe: Sending SMS to any Mobile thru Visual C++ code Pin
Junnybol8-Oct-04 4:30
Junnybol8-Oct-04 4:30 
GeneralRe: Sending SMS to any Mobile thru Visual C++ code Pin
Robert A. T. Káldy11-Oct-04 11:49
Robert A. T. Káldy11-Oct-04 11:49 
GeneralRe: Sending SMS to any Mobile thru Visual C++ code Pin
Joaquín M López Muñoz8-Oct-04 4:01
Joaquín M López Muñoz8-Oct-04 4:01 
GeneralNeed quick help w/ saving data from ListControl Pin
opt767-Oct-04 22:48
opt767-Oct-04 22:48 
GeneralRe: Need quick help w/ saving data from ListControl Pin
Anonymous9-Oct-04 14:56
Anonymous9-Oct-04 14:56 
Generalremove a dialog box Pin
SimpleProgramer7-Oct-04 22:24
SimpleProgramer7-Oct-04 22:24 
GeneralRe: remove a dialog box Pin
Sujan Christo7-Oct-04 22:28
Sujan Christo7-Oct-04 22:28 
GeneralUnhandled Exception.... :'( Pin
nutkase7-Oct-04 21:53
nutkase7-Oct-04 21:53 
GeneralRe: Unhandled Exception.... :'( Pin
toxcct7-Oct-04 22:23
toxcct7-Oct-04 22:23 
GeneralRe: Unhandled Exception.... :'( Pin
Sujan Christo7-Oct-04 22:26
Sujan Christo7-Oct-04 22:26 
GeneralRe: Unhandled Exception.... :'( (Code you people asked) Pin
nutkase7-Oct-04 23:29
nutkase7-Oct-04 23:29 
GeneralRe: Unhandled Exception.... :'( (Code you people asked) Pin
Sujan Christo8-Oct-04 0:59
Sujan Christo8-Oct-04 0:59 

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.