Click here to Skip to main content
15,923,083 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Thread issue Pin
John M. Drescher3-Jun-04 7:33
John M. Drescher3-Jun-04 7:33 
Generalmemory allocation Pin
Gérald Mercet3-Jun-04 4:42
Gérald Mercet3-Jun-04 4:42 
GeneralRe: memory allocation Pin
jmkhael3-Jun-04 5:45
jmkhael3-Jun-04 5:45 
GeneralRe: SetForegroundWindow() to a Message-Window prevents a later popped parentless-modal-dialog from showing Pin
Blake Miller3-Jun-04 3:33
Blake Miller3-Jun-04 3:33 
GeneralBeginner registry problem Pin
Scozturk3-Jun-04 3:03
professionalScozturk3-Jun-04 3:03 
GeneralRe: Beginner registry problem Pin
Dominik Reichl3-Jun-04 3:12
Dominik Reichl3-Jun-04 3:12 
GeneralRe: Beginner registry problem Pin
David Crow3-Jun-04 4:12
David Crow3-Jun-04 4:12 
Generalcasting a vector Pin
Jerome Conus3-Jun-04 2:33
Jerome Conus3-Jun-04 2:33 
Hi !

I have a vector of objects of class B. Class B is derived from class A :
A function in my application is asking for a vector of class A objects.
I want to pass my vector of B objects (which I guess should be possible because B objects are A objects, thus a vector of B objects if also a vector of A objects).

Here is a snippet of what I tried :
class A;
class B : public A;

void foo(std::vector<const A>& vect)
{
   //...
}

void main()
{
   std::vector<const B> MyVect;
   MyVect.push_back(new B);
   foo(MyVect);
}


I get a compile error, telling me that it's not possible to convert std::vector<const B> to std::vector<const A>.

How can I solve this ?

Thanks !
Jerome
GeneralRe: casting a vector Pin
cgott3-Jun-04 3:07
cgott3-Jun-04 3:07 
GeneralRe: casting a vector Pin
John M. Drescher3-Jun-04 8:03
John M. Drescher3-Jun-04 8:03 
GeneralRe: casting a vector Pin
Jerome Conus3-Jun-04 19:09
Jerome Conus3-Jun-04 19:09 
GeneralRe: casting a vector Pin
Johnny ²3-Jun-04 21:41
Johnny ²3-Jun-04 21:41 
GeneralRe: casting a vector Pin
John M. Drescher4-Jun-04 7:52
John M. Drescher4-Jun-04 7:52 
GeneralNeed help urgent please! Pin
12ed23gv54ha46rdsg6543-Jun-04 2:25
12ed23gv54ha46rdsg6543-Jun-04 2:25 
GeneralRe: Need help urgent please! Pin
David Crow3-Jun-04 4:17
David Crow3-Jun-04 4:17 
GeneralRe: Need help urgent please! Pin
Rick York3-Jun-04 6:59
mveRick York3-Jun-04 6:59 
GeneralChanging colors in VS6 image editor Pin
dart133-Jun-04 2:25
dart133-Jun-04 2:25 
GeneralSetButtonText on toolbar in DLL acts strange Pin
wimvhouts3-Jun-04 2:13
wimvhouts3-Jun-04 2:13 
GeneralToolbars with Drag/Drop functionality Pin
raed3-Jun-04 2:05
raed3-Jun-04 2:05 
GeneralRe: Toolbars with Drag/Drop functionality Pin
Iain Clarke, Warrior Programmer3-Jun-04 4:22
Iain Clarke, Warrior Programmer3-Jun-04 4:22 
GeneralRe: Toolbars with Drag/Drop functionality Pin
raed3-Jun-04 4:45
raed3-Jun-04 4:45 
GeneralRe: Toolbars with Drag/Drop functionality Pin
Iain Clarke, Warrior Programmer3-Jun-04 5:31
Iain Clarke, Warrior Programmer3-Jun-04 5:31 
QuestionThe character we get in a mouse position? Pin
golfbear3-Jun-04 1:56
golfbear3-Jun-04 1:56 
AnswerRe: The character we get in a mouse position? Pin
jmkhael3-Jun-04 2:06
jmkhael3-Jun-04 2:06 
GeneralRe: The character we get in a mouse position? Pin
golfbear3-Jun-04 3:52
golfbear3-Jun-04 3:52 

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.