Click here to Skip to main content
15,899,639 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: consecutive sums Pin
Christian Graus19-Sep-01 14:58
protectorChristian Graus19-Sep-01 14:58 
GeneralRe: consecutive sums Pin
Christian Graus19-Sep-01 16:32
protectorChristian Graus19-Sep-01 16:32 
QuestionHow do you remove help from a project? Pin
Cathy18-Sep-01 14:21
Cathy18-Sep-01 14:21 
AnswerRe: How do you remove help from a project? Pin
Tomasz Sowinski19-Sep-01 2:02
Tomasz Sowinski19-Sep-01 2:02 
GeneralRe: How do you remove help from a project? Pin
Cathy19-Sep-01 10:52
Cathy19-Sep-01 10:52 
Questionhelp, Implement Flashwindow like MNS Msg? Pin
OGIR18-Sep-01 12:30
OGIR18-Sep-01 12:30 
AnswerRe: help, Implement Flashwindow like MNS Msg? Pin
Michael P Butler18-Sep-01 22:21
Michael P Butler18-Sep-01 22:21 
Generalchar* as template parameter Pin
Aaron Schaefer18-Sep-01 12:22
Aaron Schaefer18-Sep-01 12:22 
Hi,

I've got a question about non-type template parameters. I'm passing a global char* as a parameter to a template (in addition to other stuff). Something like this:

In RecordTemplate.h
template<class record_type,="" char*="" record_name="">
RecordTemplate
{
// Methods and other neat stuff go here
};

Then in Record1.h

#include "RecordTemplate.h"

// Declare the string literals for record name
char _Record1RecordName[];

// Declare the struct type for use with the Adi record
struct Record1Struct
{
double TimeDate;
// other stuff . . .
};

// Typdef a specialization
typedef RecordTemplate<record1struct, _record1recordname=""> Record1;

And then in Record1.cpp

// Define the record name
char _Record1RecordName[] = "The name of the record";



This is working OK, and I am able to stamp out specializations of the template class. But, I want to be able to declare the char arrays as const, and initialize them in the declaration, like this (in the header file):

const char _Record1RecordName[] = "The name of the record.";

Then, I don't need the extra source file, and the records are safe from modification. I tried to use the const keyword, and I get a strange compiler error about template parameters may not be static. Apparently the const keyword affects the linkage, but I became a little confused at that point.

Has anyone tried this before? Basically, I just want to be able to pass a global const array of characters (or any other sort of const array for that matter) as a template parameter.

Thanks,

Aaron

Confused | :confused:
GeneralRe: char* as template parameter Pin
Michael Dunn18-Sep-01 21:16
sitebuilderMichael Dunn18-Sep-01 21:16 
GeneralRe: char* as template parameter Pin
Aaron Schaefer19-Sep-01 3:48
Aaron Schaefer19-Sep-01 3:48 
GeneralDebug vs Release Pin
18-Sep-01 11:58
suss18-Sep-01 11:58 
GeneralRe: Debug vs Release Pin
Tomasz Sowinski19-Sep-01 1:06
Tomasz Sowinski19-Sep-01 1:06 
GeneralWin32 Printing Problems - 32character device names. Pin
Mike Doner18-Sep-01 11:19
Mike Doner18-Sep-01 11:19 
GeneralWin2000/XP Job Kernel Object Pin
18-Sep-01 11:12
suss18-Sep-01 11:12 
GeneralMFC Extension DLL Pin
sfanjoy18-Sep-01 10:56
sfanjoy18-Sep-01 10:56 
GeneralRe: MFC Extension DLL Pin
Tomasz Sowinski18-Sep-01 11:10
Tomasz Sowinski18-Sep-01 11:10 
GeneralExecuting a database macro from VC++ Pin
duggie18-Sep-01 10:55
duggie18-Sep-01 10:55 
GeneralRe: Executing a database macro from VC++ Pin
Carlos Antollini18-Sep-01 11:01
Carlos Antollini18-Sep-01 11:01 
GeneralRe: Executing a database macro from VC++ Pin
duggie18-Sep-01 11:11
duggie18-Sep-01 11:11 
GeneralRe: Executing a database macro from VC++ Pin
Carlos Antollini18-Sep-01 11:24
Carlos Antollini18-Sep-01 11:24 
GeneralRe: Executing a database macro from VC++ Pin
duggie19-Sep-01 4:01
duggie19-Sep-01 4:01 
GeneralRe: Executing a database macro from VC++ Pin
Carlos Antollini19-Sep-01 4:23
Carlos Antollini19-Sep-01 4:23 
GeneralRe: Executing a database macro from VC++ Pin
Todd Smith18-Sep-01 11:57
Todd Smith18-Sep-01 11:57 
GeneralRe: Executing a database macro from VC++ Pin
duggie19-Sep-01 4:06
duggie19-Sep-01 4:06 
GeneralRe: Executing a database macro from VC++ Pin
Steen Krogsgaard18-Sep-01 23:06
Steen Krogsgaard18-Sep-01 23:06 

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.