<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Virtual Inheritance - Need Help in Intel® Moderncode for Parallel Architectures</title>
    <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Virtual-Inheritance-Need-Help/m-p/851084#M1876</link>
    <description>Hey there,&lt;BR /&gt;&lt;BR /&gt;I'm having a problem with class inheritance.&lt;BR /&gt;&lt;BR /&gt;Most of you probably know what Diamond Inheritance is:&lt;BR /&gt;&lt;BR /&gt;Non-Diamond Inheritance:&lt;BR /&gt;&lt;B&gt;class cBase { ... };&lt;BR /&gt;class cMiddle1 : public cBase { ... };&lt;BR /&gt;class cMiddle2 : public cBase { ... };&lt;BR /&gt;class cTop : public cMiddle1, public cMiddle2 { ... };&lt;BR /&gt;&lt;BR /&gt;cTop top; // Contains 2 instances of cBase, 1 of cMiddle1, 1 of cMiddle2, and 1 of cTop.&lt;BR /&gt;                // cTop::cMiddle1::cBase != cTop::cMiddle2::cBase&lt;BR /&gt;&lt;/B&gt;&lt;BR /&gt;Diamond Inheritance:&lt;BR /&gt;
&lt;B&gt;class cBase { ... };&lt;BR /&gt;
class cMiddle1 : public &lt;/B&gt;&lt;B&gt;virtual &lt;/B&gt;&lt;B&gt; cBase { ... };&lt;BR /&gt;
class cMiddle2 : public virtual cBase { ... };&lt;BR /&gt;
class cTop : public cMiddle1, public cMiddle2 { ... };&lt;BR /&gt;
  &lt;BR /&gt;
cTop top; // Contains ONE instance of cBase, 1 of cMiddle1, 1 of 
cMiddle2, and 1 of cTop.&lt;/B&gt;&lt;BR /&gt;                &lt;B&gt;// cTop::cMiddle1::cBase == cTop::cMiddle2::cBase&lt;/B&gt;&lt;BR /&gt;_______________________________________________________________________________&lt;BR /&gt;&lt;BR /&gt;I've hit a roadblock in my project when I tried to have virtual inheritance as shown here:&lt;BR /&gt;&lt;B&gt;class c1 : public virtual CWnd { ... };&lt;BR /&gt;class c2 : public CFormView, public c1 { &lt;/B&gt;&lt;B&gt;... DECLARE_DYNCREATE(&lt;/B&gt;&lt;B&gt;c2, &lt;/B&gt;&lt;B&gt;CFormView&lt;/B&gt;&lt;B&gt;) &lt;/B&gt;&lt;B&gt;... };&lt;BR /&gt;&lt;BR /&gt;&lt;/B&gt;Inside a function belonging to c2, I used the Watch in the debugger to test whether or not the virtual inheritance was working. It wasn't:&lt;BR /&gt;&lt;BR /&gt;&lt;B&gt;this &lt;/B&gt;= &lt;SPAN style="text-decoration: underline;"&gt;0x003b81d0&lt;/SPAN&gt;&lt;BR /&gt;&lt;B&gt;(CWnd*)(CView*)(CScrollView*)(CFormView*)this &lt;/B&gt;= &lt;SPAN style="text-decoration: underline;"&gt;0x003b81d0&lt;/SPAN&gt;&lt;BR /&gt;&lt;B&gt;(CWnd*)(c1*)this&lt;/B&gt; = &lt;SPAN style="text-decoration: underline;"&gt;0x003b829c&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;The problem is these pointers are not the same, and therefore, there are two instances of CWnd created with each creation of a c2. There should only be one instance of CWnd.&lt;BR /&gt;&lt;BR /&gt;If you know how to fix this, I'd be happy to hear your solutions!&lt;BR /&gt;&lt;BR /&gt;This issue is not specific to threading, but I think this would be a good place to post. If not, please let me know where it'd be better to ask!&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;-Steve</description>
    <pubDate>Thu, 08 Apr 2010 02:07:53 GMT</pubDate>
    <dc:creator>stephen-smolley</dc:creator>
    <dc:date>2010-04-08T02:07:53Z</dc:date>
    <item>
      <title>Virtual Inheritance - Need Help</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Virtual-Inheritance-Need-Help/m-p/851084#M1876</link>
      <description>Hey there,&lt;BR /&gt;&lt;BR /&gt;I'm having a problem with class inheritance.&lt;BR /&gt;&lt;BR /&gt;Most of you probably know what Diamond Inheritance is:&lt;BR /&gt;&lt;BR /&gt;Non-Diamond Inheritance:&lt;BR /&gt;&lt;B&gt;class cBase { ... };&lt;BR /&gt;class cMiddle1 : public cBase { ... };&lt;BR /&gt;class cMiddle2 : public cBase { ... };&lt;BR /&gt;class cTop : public cMiddle1, public cMiddle2 { ... };&lt;BR /&gt;&lt;BR /&gt;cTop top; // Contains 2 instances of cBase, 1 of cMiddle1, 1 of cMiddle2, and 1 of cTop.&lt;BR /&gt;                // cTop::cMiddle1::cBase != cTop::cMiddle2::cBase&lt;BR /&gt;&lt;/B&gt;&lt;BR /&gt;Diamond Inheritance:&lt;BR /&gt;
&lt;B&gt;class cBase { ... };&lt;BR /&gt;
class cMiddle1 : public &lt;/B&gt;&lt;B&gt;virtual &lt;/B&gt;&lt;B&gt; cBase { ... };&lt;BR /&gt;
class cMiddle2 : public virtual cBase { ... };&lt;BR /&gt;
class cTop : public cMiddle1, public cMiddle2 { ... };&lt;BR /&gt;
  &lt;BR /&gt;
cTop top; // Contains ONE instance of cBase, 1 of cMiddle1, 1 of 
cMiddle2, and 1 of cTop.&lt;/B&gt;&lt;BR /&gt;                &lt;B&gt;// cTop::cMiddle1::cBase == cTop::cMiddle2::cBase&lt;/B&gt;&lt;BR /&gt;_______________________________________________________________________________&lt;BR /&gt;&lt;BR /&gt;I've hit a roadblock in my project when I tried to have virtual inheritance as shown here:&lt;BR /&gt;&lt;B&gt;class c1 : public virtual CWnd { ... };&lt;BR /&gt;class c2 : public CFormView, public c1 { &lt;/B&gt;&lt;B&gt;... DECLARE_DYNCREATE(&lt;/B&gt;&lt;B&gt;c2, &lt;/B&gt;&lt;B&gt;CFormView&lt;/B&gt;&lt;B&gt;) &lt;/B&gt;&lt;B&gt;... };&lt;BR /&gt;&lt;BR /&gt;&lt;/B&gt;Inside a function belonging to c2, I used the Watch in the debugger to test whether or not the virtual inheritance was working. It wasn't:&lt;BR /&gt;&lt;BR /&gt;&lt;B&gt;this &lt;/B&gt;= &lt;SPAN style="text-decoration: underline;"&gt;0x003b81d0&lt;/SPAN&gt;&lt;BR /&gt;&lt;B&gt;(CWnd*)(CView*)(CScrollView*)(CFormView*)this &lt;/B&gt;= &lt;SPAN style="text-decoration: underline;"&gt;0x003b81d0&lt;/SPAN&gt;&lt;BR /&gt;&lt;B&gt;(CWnd*)(c1*)this&lt;/B&gt; = &lt;SPAN style="text-decoration: underline;"&gt;0x003b829c&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;The problem is these pointers are not the same, and therefore, there are two instances of CWnd created with each creation of a c2. There should only be one instance of CWnd.&lt;BR /&gt;&lt;BR /&gt;If you know how to fix this, I'd be happy to hear your solutions!&lt;BR /&gt;&lt;BR /&gt;This issue is not specific to threading, but I think this would be a good place to post. If not, please let me know where it'd be better to ask!&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;-Steve</description>
      <pubDate>Thu, 08 Apr 2010 02:07:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Virtual-Inheritance-Need-Help/m-p/851084#M1876</guid>
      <dc:creator>stephen-smolley</dc:creator>
      <dc:date>2010-04-08T02:07:53Z</dc:date>
    </item>
  </channel>
</rss>

