Inherit from c++ class

Is it possible for an objective-c++ class to inherit a c++ class?
I have a TON of c++ code written, but need to incorporate that into an iPhone app.
For example, consider the following cpp and mm files:
// myCPlusPlus.cpp
myCPlusPlus
virtual int cPlusPlusMethod01(someClass obj1, someClass obj2) = 0;
// myObjcClass.mm
@interface myObjcClass : myCPlusPlus // <-------is this possible being that it's a c++ class?
@end
If that's not possible, what do you recommend? Write a wrapper?
thx,
Zakk

zakkhoyt wrote:
* Objective-C++ strives to allow C++ class instances to serve as instance variables. This is possible as long as the C++ class in question (along with all of its superclasses) does not have any virtual member functions defined. If any virtual member functions are present, the C++ class may not serve as an Objective-C instance variable.
So, it turns out that I still have a problem because the architecture of our code has many classes with pure virtual functions. What now? This figures.... It'll cover every problem except mine. I really really want to keep the class interface in tact.
Any other ideas (without having to rewrite any c++ code)?
You are misreading what that really means. It specifically says "instances", not "pointers". To quote that document:
#import <Cocoa/Cocoa.h>
struct Class0 { void foo(); };
struct Class1 { virtual void foo(); };
struct Class2 { Class2(int i, int j); };
@interface Foo : NSObject {
Class0 class0; // OK
Class1 class1; // ERROR!
Class1 *ptr; // OK—call 'ptr = new Class1()' from Foo's init,
// 'delete ptr' from Foo's dealloc
Class2 class2; // WARNING - constructor not called!
@end
class0 is an instance. That is OK because it has a default constructor and no virtual functions.
class1 is also an instance. This is not OK because it has a virtual function.
ptr is the same as class1, only it is a pointer instead of an instance. This is OK. See the comments above and my own, earlier reply.
class2 is out due to the constructor.
To wrap up, you are fine. Just write some wrappers.

Similar Messages

  • Java.lang.VerifyError: Cannot inherit from final class

    Hi i am trying to call a crystal report from jsp but i am getting this error
    error:-
    org.apache.jasper.JasperException: Cannot inherit from final class
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    root cause
    javax.servlet.ServletException: Cannot inherit from final class
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
         org.apache.jsp._1_jsp._jspService(_1_jsp.java:95)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    root cause
    java.lang.VerifyError: Cannot inherit from final class
         java.lang.ClassLoader.defineClass1(Native Method)
         java.lang.ClassLoader.defineClass(Unknown Source)
         java.security.SecureClassLoader.defineClass(Unknown Source)
         org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1853)
         org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:875)
         org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1330)
         org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1209)
         java.lang.ClassLoader.loadClassInternal(Unknown Source)
         com.crystaldecisions.reports.sdk.ReportClientDocument.open(Unknown Source)
         org.apache.jsp._1_jsp._jspService(_1_jsp.java:64)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    my jsp is
    <%@ page import="com.crystaldecisions.report.web.viewer.*" %>
    <%@ page import="com.crystaldecisions.sdk.occa.report.data.*"  %>
    <%@ page import="com.crystaldecisions.reports.sdk.ReportClientDocument" %>
    <%
        Object reportSource = session.getAttribute("reportSource");
        if (reportSource == null)
           String report = "report.rpt";
           ReportClientDocument reportClientDoc = new ReportClientDocument();
           reportClientDoc.open( "report.rpt", 0);
           reportSource = reportClientDoc.getReportSource();
           session.setAttribute("reportSource", reportSource);
        CrystalReportViewer viewer = new CrystalReportViewer();
        viewer.setReportSource(reportSource);
           viewer.setEnableLogonPrompt(false); 
        viewer.setOwnPage(true);
        viewer.processHttpRequest(request, response, getServletConfig().getServletContext(), null);
    %>
    and in my WEB-INF/lib i included jar files namely
    Concurrent.jar,CrystalCharting.jar,CrystalCommon.jar,CrystalContentModels.jar,CrystalExporters.jar,CrystalExportingBase.jar,CrystalFormulas.jar,CrystalQueryEngine.jar,CrystalReportEngine.jar,CrystalReportingCommon.jar,icu4j.jar,jrcerom.jar,keycodeDecoder.jar,log4j.jar,MetafileRenderer.jar,rasapp.jar,rascore.jar,rpoifs.jar,serialization.jar,URIUtil.jar,xml-apis.jar,xbean.jar,xercesImpl.jar,webreporting.jar,webreporting-jsf.jar
    please help me

    You can't inherit from a final class. 
    So - are you trying to inherit from a final class?
    Sincerely,
    Ted Ueda

  • Jsp : Cannot inherit from final class

    hi, i have big problem.
    when i call a class using xml(DOM,SAX,...) in my jsp page, i get an error message:
    org.apache.jasper.JasperException: Cannot inherit from final class
    i don't understand why?
    help me please!!!

    Try replacing xercesImpl.jar under %Tomcat_Home%/common/endorsed with the one included with Xalan-Java.

  • Clientgen Exception - java.lang.VerifyError:Cannot inherit from final class

    When i create a client jar from webservice ear the ant taks fails with compiler errors, such as:
    CreateProxy:
    [clientgen] Generating client jar for earname.ear(WebServiceName_WS) ...
    BUILD FAILED
    java.lang.VerifyError: Cannot inherit from final class
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
    at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:480)
    at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:182)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
    at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:224)
    at weblogic.webservice.server.WebServiceFactory.loadNonArrayClass(WebServiceFactory.java:1318)
    at weblogic.webservice.server.WebServiceFactory.loadClass(WebServiceFactory.java:1293)
    at weblogic.webservice.server.WebServiceFactory.initTypeMaps(WebServiceFactory.java:384)
    at weblogic.webservice.server.WebServiceFactory.createFromMBean(WebServiceFactory.java:184)
    at weblogic.webservice.tools.build.internal.WSDLGenImpl.getWebServiceRuntime(WSDLGenImpl.java:240)
    at weblogic.webservice.tools.build.internal.WSDLGenImpl.run(WSDLGenImpl.java:135)
    at weblogic.webservice.tools.build.internal.ClientGenImpl.doClientGenFromEAR(ClientGenImpl.java:438)
    at weblogic.webservice.tools.build.internal.ClientGenImpl.run(ClientGenImpl.java:345)
    at weblogic.ant.taskdefs.webservices.clientgen.ClientGenTask.doClientGen(ClientGenTask.java:351)
    at weblogic.ant.taskdefs.webservices.clientgen.ClientGenTask.execute(ClientGenTask.java:208)
    at org.apache.tools.ant.Task.perform(Task.java:341)
    at org.apache.tools.ant.Target.execute(Target.java:309)
    at org.apache.tools.ant.Target.performTasks(Target.java:336)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1339)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1255)
    at org.apache.tools.ant.Main.runBuild(Main.java:609)
    at org.apache.tools.ant.Main.start(Main.java:196)
    at org.apache.tools.ant.Main.main(Main.java:235)
    Total time: 25 seconds
    This is a ant command:
    <clientgen ear="${build}/earname.ear" onlyConvenienceMethod="true" warName="webservice.war" serviceName="WebServiceName_WS" packageName="my.package.webservices.generated" autotype="true" clientJar="${build.dist}/client/WebServiceName_WS.jar" overwrite="false" useServerTypes="true" keepGenerated="false" generateAsyncMethods="false" saveWsdl="true" j2me="false" useLowerCaseMethodNames="true" typePackageName="my.package.webservices.generated" usePortNameAsMethodName="false" />
    My webservice do not include any final class.
    I'm using WebLogic 8.1 SP4.Is there a solution for above problem?
    Thanks.
    Regards.

    Hi all,
    I m also facing quite similar problem.
    I have one sample JMX program, which i want to collect data from weblogic 9.2.
    but when i compile sample program on jdk 1.4 and run it on JDK 1.4 it throws following exception
    java.lang.VerifyError: class weblogic.utils.classloaders.GenericCl
    assLoader overrides final method .
    ERROR 02/13 09:54:03 Stderr 700100 at java.lang.ClassLoader.defineClass0(Native Method)
    ERROR 02/13 09:54:03 Stderr 700100 at java.lang.ClassLoader.defineClass(Unknown Source)
    ERROR 02/13 09:54:03 Stderr 700100 at java.security.SecureClassLoader.defineClass(Unknown Source)
    ERROR 02/13 09:54:03 Stderr 700100 at java.net.URLClassLoader.defineClass(Unknown Source)
    ERROR 02/13 09:54:03 Stderr 700100 at java.net.URLClassLoader.access$100(Unknown Source)
    ERROR 02/13 09:54:03 Stderr 700100 at java.net.URLClassLoader$1.run(Unknown Source)
    ERROR 02/13 09:54:03 Stderr 700100 at java.security.AccessController.doPrivileged(Native Method)
    ERROR 02/13 09:54:03 Stderr 700100 at java.net.URLClassLoader.findClass(Unknown Source)
    ERROR 02/13 09:54:03 Stderr 700100 at java.lang.ClassLoader.loadClass(Unknown Source)
    ERROR 02/13 09:54:03 Stderr 700100 at java.lang.ClassLoader.loadClass(Unknown Source)
    but sample program works fine if i run it on JDK 1.5..
    can someone tell me...wats reason?
    Thanks
    Nihil

  • Python/C# class inherit from Labview Class

    Hello everyone,
    Is there any way to subclass a labview object with a class written in another langauge say python or a .net language?
    For example, I have a generic Camera.lvclass that I would like to implement for a specific camera. However, I would like to code the subclass in python. 
    My first thought was to write the python code, and then wrap it in the labview subclass using the labPython tool. Is there a better way?
    Thanks
    labjunky.

    no. a class can only inherit from one class. you can implement multiple interfaces.

  • TypeError: Error #2022: Class DS0$ must inherit from DisplayObject to link to a symbol

    Hello,
    When I tried AIR 3.7.0.1410 (ASC 2.0) to make an instance of a class that has AS linkage compiled as swc by Flash Pro,  it fails on
    TypeError: Error #2022: Class DS0$ must inherit from DisplayObject to link to a symbol
    at flash.display::Sprite/constructChildren()
        at flash.display::Sprite()
        at flash.display::MovieClip()
        at flash.display::Sprite/constructChildren()
        at flash.display::Sprite()
        at (AS-linkaged class name)
    while it's OK with AIR 3.6.0.6090.
    I'm on Windows 7 and Flash Builder 4.7. Does anyone see this issue?
    As for bug I put it here (Bug 3520793)
    https://bugbase.adobe.com/index.cfm?event=bug&id=3520793

    Hi Colin,
    Can you show me how you're embedding the asset in ASC 2.0?
    In Flash Pro, I imported a wav file into my library, configured the sound's linkage properties to export the asset, using the class name "ding". I then published the project as a .swc.
    In Flash Builder 4.7 Beta 1 (updated to ASC 2.0 Preview 3, though I don't think this is necessary for this particular test case), I created a new ActionScript Project, added the swc to my project library path, and then instantiated an instance of ding and played it. It seemed to work fine:
    package
        import flash.display.Sprite;
        import flash.media.Sound;
        public class SoundTest extends Sprite
            public function SoundTest()
                var s:Sound = new ding();
                s.play(0, 10);

  • Inherit from a graphical classe

    Hi,
    It seem to be impossible to create a new class who inherit from
    a Forte graphical class (like ArrayField for example).
    I'd like to add a new method to ArrayField so I imagine a
    new class who inherit from ArrayField.
    Does somebody knows if it is possible ?
    Thanks by advance.
    Jean-Baptiste BRIAUD
    SEMA GROUP
    16 rue Barbes
    92126 Montrouge
    France
    Tel. : 01 30 92 30 92

    Java class names should start with an uppercase letter.... and should indicate the purpose of the class, that is to say, what it represents.
    For example, the class that best describes the reason behind many postings here:
    {color:#0000ff}http://java.sun.com/javase/6/docs/api/java/nio/charset/CoderMalfunctionError.html{color}
    and the outcome of those postings:
    {color:#0000ff}http://java.sun.com/javase/6/docs/api/java/nio/charset/CoderResult.html{color}
    In lighter vein, Darryl

  • Calling a method from abstarct class

    Hi Experts,
    Am working on ABAP Objects.
    I have created an Abstract class - with method m1.
    I have implemented m1.
    As we can not instantiate an abstract class, i tried to call the method m1 directly with class name.
    But it it giving error.
    Please find the code below.
    CLASS c1 DEFINITION ABSTRACT.
      PUBLIC SECTION.
        DATA: v1 TYPE i.
        METHODS: m1.
    ENDCLASS.                    "c1 DEFINITION
    CLASS c1 IMPLEMENTATION.
      METHOD m1.
        WRITE: 'You called method m1 in class c1'.
      ENDMETHOD. "m1
    ENDCLASS.                    "c1 IMPLEMENTATION
    CALL METHOD c1=>m1.
    Please tell me what is wrong and how to solve this problem.
    Thanks in Advance.

    Micky is right, abstract means not to be instantiated. It is just a "template" which you can use for all subsequent classes. I.e you have general abstract class vehicle . For all vehicles you will have the same attributes like speed , engine type ,  strearing , gears etc and methods like start , move etc.
    In all subsequent classes (which inherit from vehicle) you will have more specific attributes for each. But all of these classes have some common things (like the ones mentioned above), so they use abstract class to define these things for all of them.
    Moreover there is no sense in creating instance (real object) of class vehicle . What kind of physical object would vehicle be? there is no such object in real world, right? For this we need to be more precise, so we create classes which use this "plan" for real vehicles. So the abstract class here is only to have this common properties and behaviour defined in one place for all objects which will have these. Abstract object however cannot be created per se. You can only create objects which are lower in hierarchy (which are specific like car , ship, bike etc).
    Hope this claryfies what we need abstract classes for.
    Regards
    Marcin

  • OOABAP-How to access the protected methos from a class

    How to access the protected methos from a class..There is a built in class..For tht class i have created a object..
    Built in class name : CL_GUI_TEXTEDIT
    method : LIMIT_TEXT.
    How to access this..help me with code

    hi,
    If inheritance is used properly, it provides a significantly better structure, as common components only
    need to be stored once centrally (in the superclass) and are then automatically available to subclasses.
    Subclasses also profit immediately from changes (although the changes can also render them invalid!).
    Inheritance provides very strong links between the superclass and the subclass. The subclass must
    possess detailed knowledge of the implementation of the superclass, particularly for redefinition, but also in
    order to use inherited components.
    Even if, technically, the superclass does not know its subclasses, the
    subclass often makes additional requirements of the superclass, for example, because a subclass needs
    certain protected components or because implementation details in the superclass need to be changed in
    the subclass in order to redefine methods.
    The basic reason is that the developer of a (super)class cannot
    normally predict all the requirements that subclasses will later need to make of the superclass.
    Inheritance provides an extension of the visibility concept: there are protected components. The visibility of
    these components lies between that of the public components (visible to all users, all subclasses, and the class itself), and private (visible only to the class itself). Protected components are visible to and can be used by all subclasses and the class itself.
    Subclasses cannot access the private components  particularly attributes) of the superclass. Private
    components are genuinely private. This is particularly important if a (super)class needs to make local
    enhancements to handle errors: it can use private components to do this without knowing or invalidating
    subclasses.
    Create your class inse24 and inherit this CL_GUI_TEXTEDIT
    class in yours. You can then access the protected methods.
    Hope this is helpful, <REMOVED BY MODERATOR>
    Edited by: Runal Singh on Feb 8, 2008 1:08 PM
    Edited by: Alvaro Tejada Galindo on Feb 19, 2008 2:19 PM

  • Unable to use Class Designer when deriving Entity Bean from another class

    I have several Entity Beans that have common fields. In order to maximise reusability, I have defined a base class which contains these common fields and corresponding get/set methods on these fields.
    In the next step, I build an Entity Bean using JDeveloper. I then go to Source Editor and in the Bean class, modify the Java code to inherit from this base class that I have defined. I then try to go to Class Designer expecting to see the inherited fields as well.
    However, this is the error I get :
    "Error while trying to parse source file...."
    Any pointers on resolving this would be a great help ! Thanks !!!
    -Andre
    null

    If you're running >Java 1.4, you'll need to put your classes into a package since Tomcat can no longer import the class 'BeanProdess' which is in an unnamed namespace.
    Your JSP is compiled into a class (in the package org.apache.jsp) that doesn't recognize anything in the default package.
    Here's a reference if you want to read about this.
    http://java.sun.com/j2se/1.4/compatibility.html#incompatibilities1.4

  • Inheriting from inner classes

    TIJ has a section on inheriting from inner classes, but the author didn't illustrate a scenario. What could be the possible usage? Why would one want to only inherit the inner case, but have to initialize the outter class (which it doesn't want to inherit)?
    Example code in the book:
        //: c08:InheritInner.java
        // Inheriting an inner class.
        class WithInner {
          class Inner {}
        public class InheritInner extends WithInner.Inner {
          //! InheritInner() {} // Won't compile
          InheritInner(WithInner wi) {
            wi.super();
          public static void main(String[] args) {
            WithInner wi = new WithInner();
            InheritInner ii = new InheritInner(wi);
        } ///:~

    I've certainly never felt the need to extend inner
    classes. As far as I'm concerned, inner classes are
    great for certain uses, all of which involve them
    being private. I've yet to find a scenario where a
    non-private inner class is preferable to a 'proper'
    class.To make the outer class act as a factory. The inner class is public but the constructors are private.

  • Inherit from LV Web Service

    I have a created a Child Web Service class that inherits from Web Service. In my Web Service startup VI I am unable to use my class, because if I put it on the connector pane in the place of the Web Service.lvclass that is there by default, I get error −67001: LabVIEW Web Services: The Web service is undefined. This tells me the class object isn't being set correctly even though it's on the connector pane.
    Can I do what I want? It would seem kind of silly if we are able to inherit from Web Service but then not use the child class in place of the parent on the Startup VI.

    Hi Greg,
    Can you provide a little more detail about your use case? Why do you want to inherit from Web Service.lvclass? Is there a reason why Web Service.lvclass does not meet your needs? I only ask because I have not found anyone else that has reported this error so I can find no information about it.
    I tried to do something similar to what I thought you were doing and are not getting error -67001:
    Can you provide any code that shows this behavior? Where do you get this error? When you start the web service? If it inherits, I would imagine it should work as you want since it has all the necessary methods/data that LabVIEW would need, but I'm not 100% certain.
     

  • Inherit from a superclass

    I need to have in my code where I inherit from a superclass.
    On the first line of my code where it uses the word extends JPanel. Am I not inheriting from a superclass?
    public class u07a1KMcKay extends JPanel
        private JTextField fahrenheitText    = new JTextField(15);
        private JTextField celciusText       = new JTextField(15);
        private JTextField messageField;
         // u07a1KMcKay constructor adds JTextFields to JPanel
        public u07a1KMcKay()
        {  ....  }

    Java class names should start with an uppercase letter.... and should indicate the purpose of the class, that is to say, what it represents.
    For example, the class that best describes the reason behind many postings here:
    {color:#0000ff}http://java.sun.com/javase/6/docs/api/java/nio/charset/CoderMalfunctionError.html{color}
    and the outcome of those postings:
    {color:#0000ff}http://java.sun.com/javase/6/docs/api/java/nio/charset/CoderResult.html{color}
    In lighter vein, Darryl

  • Inheritanc​e from CNiGraph class

    I create a new class inheriting from CNiGraph class, and add codes which display a popup menu when OnRButtonDown event occurs in the new class. However, all menu items are grayed and cannot be changed using MF_ENABLED flag.
    If I create a new class inheriting from CButton class and repeat the same process, the menu is enabled. Or if I directly respond to OnRButtonDown event of CNiGraph class, everything is ok as well.
    So, how to inherit a class in Measurement Studio?

    VI server properties are grouped by more and more specific as you go from top to bottom.  This property is in the bottom set.  LabVIEW 2009 SP1 version attached.
    This account is no longer active. Contact ShadesOfGray for current posts and information.
    Attachments:
    SetParentClass.vi ‏17 KB

  • Compilation error while calling static method from another class

    Hi,
    I am new to Java Programming. I have written two class files Dummy1 and Dummy2.java in the same package Test.
    In Dummy1.java I have declared a static final variable and a static method as you can see it below.
    package Test;
    import java.io.*;
    public class Dummy1
    public static final int var1= 10;
    public static int varDisp(int var2)
    return(var1+var2);
    This is program is compiling fine.
    I have called the static method varDisp from the class Dummy2 and it is as follows
    package Test;
    import java.io.*;
    public class Dummy2
    public int var3=15;
    public int test=0;
    test+=Dummy1.varDisp(var3);
    and when i compile Dummy2.java, there is a compilation error <identifier > expected.
    Please help me in this program.

    public class Dummy2
    public int var3=15;
    public int test=0;
    test+=Dummy1.varDisp(var3);
    }test+=Dummy1.varDisplay(var3);
    must be in a method, it cannot just be out somewhere in the class!

Maybe you are looking for

  • Dunning Key and minimum amount per dunning level

    Dear Friends, Can any one please explain the dunnig key functions? While defining the minimum amout their is two terms one is open item and another one is total amount. The definintion of total amount is all the items in an account means the items wh

  • Error while doing AUC Settlement

    Dear All While doing settlement of Asset using transaction code AIBU, I am getting the following error: Balance in transaction currency Message no. F5702 Diagnosis A balance has occurred in transaction currency 'INR' with the following details: Excha

  • Purchasing a new PowerBook

    What is the best way to transfer programs and data from an older PowerBook Pro  Mac to a new Mac?

  • How to use remote JMS in websphere5?

    I want to use JMS in another server to send message so that I config required jndi in server. When I lookup local JMS jndi(connection factory, queue) it works correctly. But when I lookup remote connectionfactory, it throws 'javax.naming.Communicatio

  • Regarding ReadDateTime in C#

    Hi, In java writeExternal method we are inserting sql date object. I guess this is how tangosol will accept (I am not sure) private java.util.Date EFFECTIVE_FROM; if (EFFECTIVE_FROM != null) out.writeDate(242, new java.sql.Date(EFFECTIVE_FROM.getTime