473,406 Members | 2,352 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,406 software developers and data experts.

Can't seem to fix C2259 compile error


Hello

I am getting this compile error:
error C2259: 'PublicTON' : cannot instantiate abstract class due to
following members: csta2less.h(1755) : see declaration of 'PublicTON'

Class is like this:
class PublicTON: public AsnType

generated .h file:
AsnType *Clone() const;

generated .cpp file:
AsnType *PublicTON::Clone() const
{
return new PublicTON(*this);
}

The AsnType class has a clone function like this:
class __declspec(dllexport) AsnType

{

public:

virtual ~AsnType();

virtual AsnType *Clone() const=0;

etc

The clone function is a pure virtual function so I have to implement it.
But I am!

How do I fix this problem?
Angus
Dec 23 '06 #1
3 3189
Angus wrote:
Hello

I am getting this compile error:
error C2259: 'PublicTON' : cannot instantiate abstract class due to
following members: csta2less.h(1755) : see declaration of 'PublicTON'

Class is like this:
class PublicTON: public AsnType
Does this line exist in the definition of PublicTON?
AsnType *PublicTON::Clone() const;

....
>
How do I fix this problem?
Not enough code to see. We can only guess.

Post a complete and compilable chunk o code that demonstrates your
problem. (if the suggested fix above does not work).

Dec 24 '06 #2
Does this line exist in the definition of PublicTON?
AsnType *PublicTON::Clone() const;
mycsta2.h in the PublicTON class there is this line:
AsnType *Clone() const;
Here is the full code (well for this class).

mycsta2.h file has:
class PublicTON: public AsnType
{
public:
enum ChoiceIdEnum
{
unknownCid = 0,
internationalCid = 1,
nationalCid = 2,
networkspecificCid = 3,
subscriberCid = 4,
abbreviatedCid = 5
};
enum ChoiceIdEnum choiceId;
union
{
IA5String *unknown;
IA5String *international;
IA5String *national;
IA5String *networkspecific;
IA5String *subscriber;
IA5String *abbreviated;
};

PublicTON() {Init();}
PublicTON(const PublicTON& that);
public:
virtual const char * typeName(void) const { return "PublicTON"; }
void Init(void);
virtual ~PublicTON() {Clear();}
void Clear();
AsnType *Clone() const;
PublicTON &operator = (const PublicTON &that);
void BDecContent (const AsnBuf &b, AsnTag tag, AsnLen elmtLen, AsnLen
&bytesDecoded/*, s env*/);
void BDec (const AsnBuf &b, AsnLen &bytesDecoded);
};
mycsta2.cpp has:
PublicTON::PublicTON(const PublicTON &that)
{
Init();
*this = that;
}
void PublicTON::Init(void)
{
// initialize choice to no choiceId to first choice and set pointer to NULL
choiceId = unknownCid;
unknown = NULL;
}
void PublicTON::Clear()
{
switch (choiceId)
{
case unknownCid:
delete unknown;
unknown = NULL;
break;
case internationalCid:
delete international;
international = NULL;
break;
case nationalCid:
delete national;
national = NULL;
break;
case networkspecificCid:
delete networkspecific;
networkspecific = NULL;
break;
case subscriberCid:
delete subscriber;
subscriber = NULL;
break;
case abbreviatedCid:
delete abbreviated;
abbreviated = NULL;
break;
} // end of switch
} // end of Clear()
AsnType *PublicTON::Clone() const
{
return new PublicTON(*this);
}
PublicTON &PublicTON::operator = (const PublicTON &that)
{
if (this != &that)
{
Clear();
// Check first type in choice to determine if choice is empty
if (that.unknown != NULL)
{
switch (choiceId = that.choiceId)
{
case unknownCid:
unknown = new IA5String(*that.unknown);
break;
case internationalCid:
international = new IA5String(*that.international);
break;
case nationalCid:
national = new IA5String(*that.national);
break;
case networkspecificCid:
networkspecific = new IA5String(*that.networkspecific);
break;
case subscriberCid:
subscriber = new IA5String(*that.subscriber);
break;
case abbreviatedCid:
abbreviated = new IA5String(*that.abbreviated);
break;
}// end of switch
}// end of if
}
return *this;
}
void PublicTON::BDecContent (const AsnBuf &b, AsnTag tag, AsnLen elmtLen0,
AsnLen &bytesDecoded/*, s env*/)
{
FUNC("PublicTON::BDecContent()");
Clear();
switch (tag)
{
case MAKE_TAG_ID (CNTX, PRIM, 0):
case MAKE_TAG_ID (CNTX, CONS, 0):
choiceId = unknownCid;
unknown = new IA5String;
unknown->BDecContent (b, tag, elmtLen0, bytesDecoded);
break;
case MAKE_TAG_ID (CNTX, PRIM, 1):
case MAKE_TAG_ID (CNTX, CONS, 1):
choiceId = internationalCid;
international = new IA5String;
international->BDecContent (b, tag, elmtLen0, bytesDecoded);
break;
case MAKE_TAG_ID (CNTX, PRIM, 2):
case MAKE_TAG_ID (CNTX, CONS, 2):
choiceId = nationalCid;
national = new IA5String;
national->BDecContent (b, tag, elmtLen0, bytesDecoded);
break;
case MAKE_TAG_ID (CNTX, PRIM, 3):
case MAKE_TAG_ID (CNTX, CONS, 3):
choiceId = networkspecificCid;
networkspecific = new IA5String;
networkspecific->BDecContent (b, tag, elmtLen0, bytesDecoded);
break;
case MAKE_TAG_ID (CNTX, PRIM, 4):
case MAKE_TAG_ID (CNTX, CONS, 4):
choiceId = subscriberCid;
subscriber = new IA5String;
subscriber->BDecContent (b, tag, elmtLen0, bytesDecoded);
break;
case MAKE_TAG_ID (CNTX, PRIM, 5):
case MAKE_TAG_ID (CNTX, CONS, 5):
choiceId = abbreviatedCid;
abbreviated = new IA5String;
abbreviated->BDecContent (b, tag, elmtLen0, bytesDecoded);
break;
default:
throw InvalidTagException(typeName(), tag, STACK_ENTRY);
break;
} // end switch
} // PublicTON::BDecContent

void PublicTON::BDec (const AsnBuf &b, AsnLen &bytesDecoded)
{
AsnLen elmtLen;
AsnTag tag;
/* CHOICEs are a special case - grab identifying tag */
/* this allows easier handling of nested CHOICEs */
tag = BDecTag (b, bytesDecoded);
elmtLen = BDecLen (b, bytesDecoded);
BDecContent (b, tag, elmtLen, bytesDecoded);
}
PrivateTON::PrivateTON(const PrivateTON &that)
{
Init();
*this = that;
}

and the mycsta2.h file #include "asn-incl.h" which has AsnType class like
this:
class SNACCDLL_API AsnType
{
public:
virtual ~AsnType();
virtual AsnType *Clone() const=0;
virtual void BDec (const AsnBuf &b, AsnLen &bytesDecoded)=0;
virtual AsnLen BEnc (AsnBuf &b) const =0 ;
bool BEncPdu (AsnBuf &b, AsnLen &bytesEncoded) const;
bool BDecPdu (const AsnBuf &b, AsnLen &bytesDecoded);
virtual void Print (std::ostream &) const=0;
virtual const char * typeName(void) const { return "AsnType"; }
#if META
static const AsnTypeDesc _desc;
virtual const AsnTypeDesc *_getdesc() const;
virtual AsnType *_getref (const char *membername, bool create=false);
private:
const char *_typename() const;
#if TCL
public:
virtual int TclGetDesc (Tcl_DString *) const;
virtual int TclGetVal (Tcl_Interp *) const;
virtual int TclSetVal (Tcl_Interp *, const char *val);
virtual int TclUnsetVal (Tcl_Interp *, const char *membernames);
#endif // TCL
#endif // META
};
"Gianni Mariani" <gi*******@mariani.wswrote in message
news:45***********************@per-qv1-newsreader-01.iinet.net.au...
Angus wrote:
Hello

I am getting this compile error:
error C2259: 'PublicTON' : cannot instantiate abstract class due to
following members: csta2less.h(1755) : see declaration of 'PublicTON'

Class is like this:
class PublicTON: public AsnType

Does this line exist in the definition of PublicTON?
AsnType *PublicTON::Clone() const;

...

How do I fix this problem?

Not enough code to see. We can only guess.

Post a complete and compilable chunk o code that demonstrates your
problem. (if the suggested fix above does not work).

Dec 24 '06 #3
Angus wrote:
....
class SNACCDLL_API AsnType
{
public:
virtual ~AsnType();
virtual AsnType *Clone() const=0;
virtual void BDec (const AsnBuf &b, AsnLen &bytesDecoded)=0;
virtual AsnLen BEnc (AsnBuf &b) const =0 ;
It seems you don't provide an implementation of BEnc in your derived
class. That would cause the derived class to be abstract and hence
uninstantiable.
Dec 24 '06 #4

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

Similar topics

5
by: Jerry Hull | last post by:
I'm working with a database developed by an untrained person over several years - and on a network that has recently been upgraded with a new server installed and MS office upgraded from 2K (I...
7
by: alphatan | last post by:
Is there relative source or document for this purpose? I've searched the index of "Mastering Regular Expression", but cannot get the useful information for C. Thanks in advanced. -- Learning...
12
by: JS | last post by:
I use winXP and have installed Cygwin. I use Dev-C++ and the Cygwin compiler, but for some reason I can't compile this code: #include <setjmp.h> #include <stdio.h> #include <stdlib.h> ...
1
by: Larry | last post by:
These is a interface " IPerson" and a class "SoftwareDeveloper" support the interface; public __gc __interface IPerson { void Eat(); void Sleep(; void Work();
7
by: Simon Bond | last post by:
In C# we can go: <foo.cs> // Create a serializable class public class Foo : ISerializable { public void GetObjectData(SerializationInfo info, StreamingContext context) {};
8
by: Boni | last post by:
Please help C# how to convert this C# to MC++ public void Execute(object application, int hwndOwner, ref object contextParams, ref object customParams, ref EnvDTE.wizardResult retval) ; I tried...
52
by: Jim Langston | last post by:
I wanted to do an operator override for but couldnt' figure out the syntax. I tried this (code that doesn't compile commented out with //: class CMyBitmap { public: CMyBitmap( int Rows, int...
15
by: key9 | last post by:
Why still can't compile (simple) Hi all I have nothing to say , the code still can not be complie, where's problem? ========================================= //test.cpp #include <stdio.h>...
1
by: gozlemci | last post by:
Hi everybody; During my coding, I have encountered a problem.I appreciate if anybody answer it. Here is the simplified code: //Header5.h #pragma once #include <string> using namespace std;
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.