473,382 Members | 1,367 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Abstract constructor initialisers


I have a class derived from an abstract base class, which is in turn
derived from a further ABC:

template< typename T > class CAbstractMatrix{...};

template< typename T > class CAbstractSquareMatrix: public
CAbstractMatrix< T >{...};

template< typename T > class CDiagonalMatrix : public
CAbstractSquareMatrix< T >{...};

Can anyone tell me why this constructor initialiser:

template< typename T > CDiagonalMatrix< T >::CDiagonalMatrix( unsigned
long nRows, T* pData, bool bAdopt = false )

: CAbstractSquareMatrix< T >( pData, nRows, bAdopt ) // works

{

...

}

calls CAbstractSquareMatrix< T >::CAbstractSquareMatrix( unsigned long,
T*, bool) as intended, but the latter:

template< typename T > CAbstractSquareMatrix< T
::CAbstractSquareMatrix( T* pData, unsigned long nSize, bool


bAdopt = false )

: CAbstractMatrix< T >( pData, nSize, bAdopt ) // doesn't work!

{

...

}

fails to call CAbstractMatrix< T >::CAbstractMatrix( T*, unsigned long,
bool) in its turn? Everything compiles fine; don't be put off by my
changing the order of the parameters between classes. The code fails at
run-time because the base-base-class's constructor is not called.

Thanks,

tom
--
Posted via http://dbforums.com
Jul 19 '05 #1
1 2320
major_tom3 wrote:
I have a class derived from an abstract base class, which is in turn
derived from a further ABC:

template< typename T > class CAbstractMatrix{...};

template< typename T > class CAbstractSquareMatrix: public
CAbstractMatrix< T >{...};

template< typename T > class CDiagonalMatrix : public
CAbstractSquareMatrix< T >{...};

Can anyone tell me why this constructor initialiser:

template< typename T > CDiagonalMatrix< T >::CDiagonalMatrix( unsigned
long nRows, T* pData, bool bAdopt = false )
: CAbstractSquareMatrix< T >( pData, nRows, bAdopt ) // works
{
...
}

calls CAbstractSquareMatrix< T >::CAbstractSquareMatrix( unsigned long,
T*, bool) as intended, but the latter:

template< typename T > CAbstractSquareMatrix< T >::CAbstractSquareMatrix(
T* pData, unsigned long nSize, bool bAdopt = false )
: CAbstractMatrix< T >( pData, nSize, bAdopt ) // doesn't work!
{
...
}

fails to call CAbstractMatrix< T >::CAbstractMatrix( T*, unsigned long,
bool) in its turn? Everything compiles fine; don't be put off by my
changing the order of the parameters between classes. The code fails at
run-time because the base-base-class's constructor is not called.


I have no problems with this implementation.

Can you specify the compiler and platform you are using, and also post
working code.

Ryan

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Tee | last post by:
Hi, I have a base usercontrol with a method (blank method, no code), I have another few usercontrols that will inherit this base usercontrol, but I want to force all the usercontrol that...
12
by: Daedalus.OS | last post by:
Ok first I'm pretty new to OOP, so my question may sound stupid to some of you. If the only answer you can provide is "get a book about OOP" then don't loose your time and mine cause it's already...
10
by: Gniluy | last post by:
Hi, I have a protected method that I only want it to be called from code in constructor or from methods called by constructor. If it is not called directly or indirectly from constructor, I want...
7
by: erin.sebastian | last post by:
Hello Everyone, This is my first attempt at coding using an abstract class and i am getting an error i can't figure out. Here is the back ground. I have a project that contains an abstract...
3
by: WithPit | last post by:
I am trying to create an managed wrapper but have some problems with it by using abstract classes. In my unmanaged library code i had the following three classes with the following hierarchy ...
17
by: baibaichen | last post by:
i have written some code to verify how to disable slicing copy according C++ Gotchas item 30 the follow is my class hierarchy, and note that B is abstract class!! class B { public: explicit...
22
by: ypjofficial | last post by:
Hello All, I have following doubt.. class abstractclass { public: abstractclass(){} virtual void method()=0; };
17
by: Jess | last post by:
Hello, If I have a class that has virtual but non-pure declarations, like class A{ virtual void f(); }; Then is A still an abstract class? Do I have to have "virtual void f() = 0;"...
4
by: Pranav | last post by:
Hello All, I have a simple question regarding the definition of abstract class, IIRC , Abstract class is one which contains virtual function declaration and other variables and no object of this...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.