Solved

An object of abstract class cannot be created

Posted on 2010-11-08
11
862 Views
Last Modified: 2012-06-27
hi,

when i try to compile my source code, i get this error:

"/development/demusr/osrc/hello_02/hello_02-0.0.0/libsrc/CustRegister.cxx", line 6.44: 1540-1107 (S) An object of abstract class "CustLoaderFactory" cannot be created.
"/development/demusr/include/SdkTargetFactory.h", line 44.21: 1540-1112 (I) "TargetFactory<TsfLoader>::createCondition(char *, const void *)" is a pure virtual function.
"/development/demusr/include/SdkTargetFactory.h", line 58.25: 1540-1112 (I) "TargetFactory<TsfLoader>::getTargetObj(char *, const void *)" is a pure virtual function.
"/development/demusr/include/ObjectCollector.h", line 55.23: 1540-1112 (I) "ObjectCollector<TsfLoader>::createInstance(const char *, const void *)" is a pure virtual function.
"/development/demusr/include/ObjectCollector.h", line 56.22: 1540-1112 (I) "ObjectCollector<TsfLoader>::reuseInstance(TsfLoader *, const char *, const void *)" is a pure virtual function.
"/development/demusr/osrc/hello_02/hello_02-0.0.0/libsrc/../include/CustRegistration.h", line 15.40: 1540-0202 (S) An expression of type "void *" is not allowed on the left side of "->".

Appreciate if you can advise on this with some explaination.
Thank you in advance.
header file

===========



#ifndef _CUSTLOADERFACTORY_H_

#define _CUSTLOADERFACTORY_H_



#include <TsfLoader.h>

#include <SdkTargetFactory.h>

#include <ObjectCollector.h>



class CustLoaderFactory : public TargetFactory<TsfLoader>

                                                        ,public ObjectCollector<TsfLoader>

{

    public:

        virtual int createCondition(char *condition, void *entity_type);

        virtual TsfLoader *getTargetObj(char *condition, void *entity_type);

        virtual TsfLoader *createInstance(const char *condition, void *entity_type);

        virtual int reuseInstance(TsfLoader *instance, const char *condition, void *entity_type);

};

#endif



source file

===========



#include <CustomerCard.h>

// Included all customized loader classes headers here

#include "CustLoaderFactory.h"



//entity_type is passed in as a string for now

CustLoaderFactory::createCondition(char *condition, void *entity_type)

{

    strcpy(condition, (char *)entity_type);

    return 0;

}



TsfLoader *CustLoaderFactory::getTargetObj(char *condition, void *entity_type)

{

    return getObject(condition, entity_type);

}



TsfLoader *CustLoaderFactory::createInstance(const char *condition, void *name)

{

    TsfLoader *obj = NULL;

    if (strcmp(condition, ENTITY_TYPE_CARD) == 0)

        obj = new CustomerCard();

    else

        obj = NULL;



    if ( obj )

        OTraceDebug("D-CUSTTSF-0001: Create Instance[%s]\n", condition);

    else

        OTraceError("F-CUSTTSF-0002: Unknown Object Name[%s]\n", condition);



    return obj;

}



int CustLoaderFactory::reuseInstance(TsfLoader *instance, const char *condition, void *entity_type)

{

    return 0;

}

Open in new window

0
Comment
Question by:gagajanice
11 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 34090964
can u post SdkTargetFactory.h?
0
 
LVL 40

Accepted Solution

by:
evilrix earned 350 total points
ID: 34091062
You need to implement those functions in your derived class and the function signatures MUST be identical.

The functions that need overriding are:

TargetFactory::createCondition(char *, const void *)
TargetFactory::getTargetObj(char *, const void *)
ObjectCollector::createInstance(const char *, const void *)
ObjectCollector::reuseInstance(TsfLoader *, const char *, const void *)

Since they are pure and virtual the compiler has no idea what they do until you implement them in your derived class.
0
 
LVL 17

Expert Comment

by:sweetfa2
ID: 34091566
You are also trying to instantiate a class of CustLoaderFactory where it is abstract.  You need to instantiate a derived class rather than the abstract class.  If you are just using a reference to a CustLoaderFactory instance in CustRegister.cxx then you don;t need to create it, you just need to refer to an existing instance.
0
 
LVL 40

Expert Comment

by:evilrix
ID: 34091744
>> You are also trying to instantiate a class of CustLoaderFactory where it is abstract.

It's not abstract, none of the members are pure virtual.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 17

Expert Comment

by:sweetfa2
ID: 34091864
/development/demusr/osrc/hello_02/hello_02-0.0.0/libsrc/CustRegister.cxx", line 6.44: 1540-1107 (S) An object of abstract class "CustLoaderFactory" cannot be created.

>> It's not abstract, none of the members are pure virtual.


No - I guess not.
0
 
LVL 5

Expert Comment

by:Xper4net
ID: 34092531
Abstract status is inherited while all interfaces or pure virtual functions from base classes are not implemented.
I dont know OjectCollector.h and SdkTargetFactory.h, so I can't guess what implementation are required, but it's inside them that you'll find the solution.
0
 

Author Closing Comment

by:gagajanice
ID: 34098485
The argument type that i declared in my header file and source file is different from the OjectCollector.h and SdkTargetFactory.h. My bad for not paying enough attention to it. Thanks guys!
0
 
LVL 40

Expert Comment

by:evilrix
ID: 34098545
>> The argument type that i declared in my header file and source file is different from the OjectCollector.h and SdkTargetFactory.h

What aregument type do you refer? Function arguments? I explained in http:#34091062 exactly why you were getting the error. You were subclassing abstract classes so you either needed to implement the exact same functions as those that were in the base classes that were pure virtual or not sublclass abstract classes.

Can you expand on that because it doesn't explain how you fixed the issue?

Also, I don't see how the answers you've selected answer your problem.
0
 
LVL 40

Expert Comment

by:evilrix
ID: 34128586
#3 - http:#34091062 explained exactly what the error was and what steps needed to be taken to fix it.

No other post provided an reason for the error or a solution.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Issue accessing member variable of atomic class 16 110
FMX StringGrid1->Canvas->FillRect Problem 3 129
How to convert MFC APP to Win32 APP. 19 71
Path to  STL Map header file 1 44
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now