Click here to Skip to main content
15,885,365 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: std::wstring cannot convert from char[3] to class std::basic_string................. Pin
egerving10-Sep-09 8:53
egerving10-Sep-09 8:53 
GeneralRe: std::wstring cannot convert from char[3] to class std::basic_string................. Pin
Rajesh R Subramanian10-Sep-09 9:12
professionalRajesh R Subramanian10-Sep-09 9:12 
AnswerRe: std::wstring cannot convert from char[3] to class std::basic_string................. Pin
Stuart Dootson10-Sep-09 11:05
professionalStuart Dootson10-Sep-09 11:05 
Questionfwrite for unicode big endian Pin
Rakesh510-Sep-09 8:17
Rakesh510-Sep-09 8:17 
AnswerRe: fwrite for unicode big endian Pin
Selvam R10-Sep-09 8:53
professionalSelvam R10-Sep-09 8:53 
GeneralRe: fwrite for unicode big endian Pin
Rakesh510-Sep-09 9:08
Rakesh510-Sep-09 9:08 
GeneralRe: fwrite for unicode big endian Pin
Selvam R10-Sep-09 9:34
professionalSelvam R10-Sep-09 9:34 
Questionreturning by reference and polymorphism Pin
paolosh10-Sep-09 8:11
paolosh10-Sep-09 8:11 
Hi all,

Having a problem with polymorphism and returning a class from a function.

Suppose I have base class B which is used to derive D1, D2, D3, D4, etc..

Suppose a function of B, myFunc(), has return of type B, and myFunc() creates within it a D1, D2, D3, or D4 and returns it.

If I were to try the following in a separate, or main(), function somewhere else,...

B rtn_instance = B::myFunc();

....how come rtn_instance is still of type B and not of type D1, D2, D3, etc... ?

I thought the polymorphism would make rtn_instance of type D1, D2, etc...

Maybe references would be helpful, but doesn't using references pose a memory leak risk, or do the pointed to objects get destroyed on exit from the calling function?

Many thanks for any help.
AnswerRe: returning by reference and polymorphism Pin
paolosh10-Sep-09 9:46
paolosh10-Sep-09 9:46 
AnswerRe: returning by reference and polymorphism Pin
Iain Clarke, Warrior Programmer10-Sep-09 9:48
Iain Clarke, Warrior Programmer10-Sep-09 9:48 
AnswerRe: returning by reference and polymorphism Pin
Iain Clarke, Warrior Programmer10-Sep-09 9:49
Iain Clarke, Warrior Programmer10-Sep-09 9:49 
AnswerRe: returning by reference and polymorphism Pin
CPallini10-Sep-09 9:59
mveCPallini10-Sep-09 9:59 
GeneralRe: returning by reference and polymorphism Pin
paolosh10-Sep-09 11:35
paolosh10-Sep-09 11:35 
Questiontic tac toe Pin
sam_200910-Sep-09 5:18
sam_200910-Sep-09 5:18 
QuestionRe: tic tac toe Pin
David Crow10-Sep-09 5:20
David Crow10-Sep-09 5:20 
AnswerRe: tic tac toe Pin
PIEBALDconsult10-Sep-09 5:58
mvePIEBALDconsult10-Sep-09 5:58 
AnswerRe: tic tac toe Pin
Keith Barrow10-Sep-09 5:26
professionalKeith Barrow10-Sep-09 5:26 
GeneralRe: tic tac toe Pin
Selvam R10-Sep-09 7:29
professionalSelvam R10-Sep-09 7:29 
AnswerRe: tic tac toe Pin
Richard MacCutchan10-Sep-09 7:34
mveRichard MacCutchan10-Sep-09 7:34 
AnswerWrong forum. Pin
CPallini10-Sep-09 8:31
mveCPallini10-Sep-09 8:31 
GeneralRe: Wrong forum. Pin
EliottA10-Sep-09 8:33
EliottA10-Sep-09 8:33 
AnswerRe: tic tac toe Pin
jinjiashan10-Sep-09 16:49
jinjiashan10-Sep-09 16:49 
QuestionCreating a Time Provider in C++ Pin
bijumanjeri10-Sep-09 5:11
bijumanjeri10-Sep-09 5:11 
AnswerRe: Creating a Time Provider in C++ Pin
David Crow10-Sep-09 5:18
David Crow10-Sep-09 5:18 
GeneralRe: Creating a Time Provider in C++ Pin
bijumanjeri10-Sep-09 5:30
bijumanjeri10-Sep-09 5:30 

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.