Click here to Skip to main content
15,900,461 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: It is possible ? Pin
Member 16246231-May-04 0:06
Member 16246231-May-04 0:06 
GeneralCreating custom tooltips Pin
vikashparida30-May-04 20:24
vikashparida30-May-04 20:24 
GeneralRe: Creating custom tooltips Pin
*test*30-May-04 21:59
*test*30-May-04 21:59 
Generalquery reg patches Pin
Member 115017630-May-04 19:37
Member 115017630-May-04 19:37 
GeneralQuery reg patches Pin
ykutanoor30-May-04 19:35
ykutanoor30-May-04 19:35 
Questionwhy view2 can printpreview and view1 can not? Pin
fffly30-May-04 18:11
fffly30-May-04 18:11 
GeneralGUI: Title bar Pin
TrungHuynh30-May-04 17:29
TrungHuynh30-May-04 17:29 
GeneralC++ Function template help Pin
Indrawati30-May-04 17:16
Indrawati30-May-04 17:16 
Hi I have created a template function as follows:

template <typename T> perform(int iTotal)
{
vector<T> vec;
for(int i = 0; i < iTotal; i++)
{
vec.push_back(T());
}
}

and I call the function in main() using the following:

perform<double>(1000);

The program compiles and links without any error, but when I run it, I always get the message: Instruction at "0x...." referenced memory at "0x...". The memory could not be written!

Could someone tell me what I did wrong, and how I can rectify it?

BTW, if I changed the function definition to

template <typename T> perform(int iTotal, T NoUse);

where NoUse is not used at all in the function, the program runs perfectly. My only gripe is that the solution does not seem elegant.

Thanks!
GeneralRe: C++ Function template help Pin
Andrew Walker30-May-04 20:12
Andrew Walker30-May-04 20:12 
GeneralRe: C++ Function template help Pin
Indrawati30-May-04 20:18
Indrawati30-May-04 20:18 
GeneralRe: C++ Function template help Pin
Paul Ranson31-May-04 13:09
Paul Ranson31-May-04 13:09 
GeneralRe: C++ Function template help Pin
Indrawati31-May-04 16:04
Indrawati31-May-04 16:04 
GeneralRe: C++ Function template help Pin
Paul Ranson1-Jun-04 6:10
Paul Ranson1-Jun-04 6:10 
QuestionCWebBrowser OnResizeTo event? Pin
surfordie30-May-04 17:14
surfordie30-May-04 17:14 
AnswerRe: CWebBrowser OnResizeTo event? Pin
Anthony_Yio31-May-04 1:17
Anthony_Yio31-May-04 1:17 
QuestionCFile::Open Timeout's?? Pin
shultas30-May-04 15:23
shultas30-May-04 15:23 
AnswerRe: CFile::Open Timeout's?? Pin
Anthony_Yio31-May-04 0:40
Anthony_Yio31-May-04 0:40 
GeneralAccess key Pin
JR Shih30-May-04 14:47
JR Shih30-May-04 14:47 
GeneralRe: Access key Pin
Anthony_Yio31-May-04 0:51
Anthony_Yio31-May-04 0:51 
GeneralRe: Access key Pin
JR Shih31-May-04 2:25
JR Shih31-May-04 2:25 
Generalsending messages to the main window Pin
kfaday30-May-04 14:32
kfaday30-May-04 14:32 
GeneralRe: sending messages to the main window Pin
Ryan Binns30-May-04 18:07
Ryan Binns30-May-04 18:07 
GeneralRe: sending messages to the main window Pin
kfaday31-May-04 2:49
kfaday31-May-04 2:49 
GeneralRe: sending messages to the main window Pin
Anthony_Yio31-May-04 0:59
Anthony_Yio31-May-04 0:59 
GeneralRe: sending messages to the main window Pin
kfaday31-May-04 2:50
kfaday31-May-04 2:50 

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.