Click here to Skip to main content
15,920,217 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
AnswerRe: HUH!!!!!!! Eliza?? Pin
Curtis Schlak.25-Nov-05 4:47
Curtis Schlak.25-Nov-05 4:47 
QuestionOutput to a printer in Managed C++ Console Pin
Simon Cornish24-Nov-05 4:41
Simon Cornish24-Nov-05 4:41 
Questionaccess and vb6 Pin
RiNaZaiNoN23-Nov-05 15:35
RiNaZaiNoN23-Nov-05 15:35 
AnswerRe: access and vb6 Pin
toxcct23-Nov-05 21:57
toxcct23-Nov-05 21:57 
Questionaccess and vb6 Pin
RiNaZaiNoN23-Nov-05 15:34
RiNaZaiNoN23-Nov-05 15:34 
AnswerRe: access and vb6 Pin
toxcct23-Nov-05 21:53
toxcct23-Nov-05 21:53 
QuestionCalling dll functions in .net Pin
ramenk23-Nov-05 1:07
ramenk23-Nov-05 1:07 
QuestionStoring Objects Pin
RichardS22-Nov-05 23:31
RichardS22-Nov-05 23:31 
Hi All,

I have an issue storing derived class objects and calling their overloaded member functions. To illistrate the problem, picture this:

<br />
class Base<br />
{<br />
public:<br />
 virtual void func1 (int i) { cout << i << endl; }<br />
};<br />
<br />
class A : public Base<br />
{<br />
public:<br />
 virtual void func1 (int i) { cout << "i - " << i << endl; }<br />
};<br />
<br />
class B : public Base<br />
{<br />
public:<br />
 virtual void func1 (int i) { cout << "i : " << i << endl; }<br />
};<br />
<br />
void global_func (Base& B) { B.func1 (1); }<br />


In this e.g. you can send A, B or Base into global_func. Now we want to link A and B together so we create a seq class and overload the operator >>:
<br />
class seq : public Base<br />
{<br />
public:<br />
 seq (A _a, B _b) : m_a (_a), m_b (_b) {  }<br />
 A& m_a;<br />
 B& m_b;<br />
 void func1 (int i) { m_a.func1 (i); m_b.func1 (i); }<br />
};<br />
<br />
seq operator>> (A& _a, B& _b) { return seq (_a, _b); }<br />


Now we can write objA >> ObjB, to do both func1 in A and B at the same time. We inherit from base, because then we can pass seq in global_func. However linking a whole string together become quite irritating esp. when you use ObjA >> ObjB often.

So this is the problem, how do you store the seq generically (i.e. if there is a sequence that does B before A, but would like to it in the same object).

I thought about using a collect class:
<br />
class collect<br />
{<br />
public:<br />
 collect (Base& B) : m_base (b) { }<br />
 Base m_base;<br />
 void func1 (int i) { m_base.func1 (i); }<br />
};<br />


But when I create the collect and global_func calls func1, it calls it in Base not seq Frown | :(

Idea's, or have I just missed the plot? Confused | :confused:


thanks,
Rich


"Programming today is a race between software engineers striving to build bigger and
better idiot-proof programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
QuestionUse of virtual destructors? Pin
G Haranadh22-Nov-05 23:21
G Haranadh22-Nov-05 23:21 
AnswerRe: Use of virtual destructors? Pin
RichardS23-Nov-05 1:10
RichardS23-Nov-05 1:10 
QuestionHaving trouble with a namespace and class type collision in C++/C# project Pin
dxben22-Nov-05 18:06
dxben22-Nov-05 18:06 
AnswerRe: Having trouble with a namespace and class type collision in C++/C# project Pin
Sheng Jiang 蒋晟24-Nov-05 19:46
Sheng Jiang 蒋晟24-Nov-05 19:46 
GeneralRe: Having trouble with a namespace and class type collision in C++/C# project Pin
dxben5-Dec-05 17:05
dxben5-Dec-05 17:05 
GeneralRe: Having trouble with a namespace and class type collision in C++/C# project Pin
Sheng Jiang 蒋晟5-Dec-05 18:27
Sheng Jiang 蒋晟5-Dec-05 18:27 
GeneralRe: Having trouble with a namespace and class type collision in C++/C# project Pin
dxben6-Dec-05 0:25
dxben6-Dec-05 0:25 
QuestionPlot in C++ Pin
Mareo_42122-Nov-05 13:22
Mareo_42122-Nov-05 13:22 
AnswerRe: Plot in C++ Pin
Saksida Bojan22-Nov-05 19:54
Saksida Bojan22-Nov-05 19:54 
QuestionI need help 2 Pin
Harshees22-Nov-05 12:54
Harshees22-Nov-05 12:54 
AnswerRe: I need help 2 Pin
toxcct23-Nov-05 2:13
toxcct23-Nov-05 2:13 
AnswerRe: I need help 2 Pin
Saksida Bojan23-Nov-05 18:53
Saksida Bojan23-Nov-05 18:53 
QuestionI need help! Pin
Harshees22-Nov-05 12:52
Harshees22-Nov-05 12:52 
QuestionXmlValidatingReader problem with xs:date Pin
IsaacB22-Nov-05 10:28
IsaacB22-Nov-05 10:28 
QuestionEditor for collapsing '#ifdef' or '#if defined' in C/C++ files Pin
kristofvanderhaeghen21-Nov-05 21:44
kristofvanderhaeghen21-Nov-05 21:44 
QuestionHow to change CEdit's background color and text color? thanks. Pin
LeeeNN21-Nov-05 14:12
LeeeNN21-Nov-05 14:12 
QuestionFailed to retrieve SQL Server out param values using ADODB::_CommandPtr - Urgent Pin
shyjujohn21-Nov-05 1:00
shyjujohn21-Nov-05 1:00 

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.