-
May 27th, 2007, 09:26 PM
#1
[RESOLVED] Issue with ABCs - ERROR C2259
Hi,
I am getting trouble to make my ABC working.
I can not compile my dll as soon as I use an ABC. The compiler tells me error C2259: 'xlINSTRUMENTS' : cannot instantiate abstract class
I have searched around and I thought it was a signature problem but it does not look like since the 2 functions are really the same.
I thouth also it was a problem of object creation but it is unlikely also.
In order to create my xlMM object, I write the following line:
xlINSTRUMENTS * abc = new xlMM(..........);
with xlMM(..........) being the correct constructor.
or xlINSTRUMENTS abc = xlMM( ..... ) if I want to create the object it self and not a pointer.
I am under Visual studio .NET 2003 and I am trying to compile a Multithreaded dll.
I have enclosed the code at the end in order to be complete.
Any help would be greatly appreciated.
Lapin
//Abstract class definition
class xlINSTRUMENTS
{
private:
std::string Name;
public:
virtual double RetrieveInstrument( const double & ,const double & ) const = 0 ;
}
//Derived class definition
class xlMMublic xlINSTRUMENTS
{
private:
...
public:
virtual double RetrieveInstrument(const double & ,const double & ) const ;
};
//virtual fonction definition
double xlMM::RetrieveInstrument( const double &InputHeader ,const double &InputValue ) const
{
return InputHeader;
};
-
May 27th, 2007, 09:43 PM
#2
Re: Issue with ABCs - ERROR C2259
An ABC acts solely as a base class for inherited classes. You cannot instantiate an ABC - you must instantiate one of the derived classes using new and assign it to a pointer to the base ABC.
Code:
xlINSTRUMENTS *pABC = new xlMM(...);
Regards
Alan
-
May 27th, 2007, 10:15 PM
#3
Re: Issue with ABCs - ERROR C2259
Thanks Alan.
I should have thought a little bit longer.
Anyway case solved.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|