How to use one variable for 2 datatype inside class

Dear all
i have create 2 class GDI and OGL need use use in M_VIEW as per condition
in the class M_VIEW (example below)
#define M_FLAG 1
class GDI {public: int z;};
class OGL{public: double z;};
// in class M_VIEWi need to use GDI or OGL as per user condition
class M_VIEW{
public:
#if (M_FLAG == 1)
GID UseThis;
#else
OGL UseThis;
#endif
this is work but it always it take OGL. of if i change condition it take GDI only. but i need to use it runtime as per user choice.
how to switch GDI to OGL, and OGL to GDI on runtime ;
is that possible to change M_FLAG  value on run time or is there any other way to achieve it.
i have try with polymorphism also. switch is ok but all function does not work with dll. when call function on mouse move or some other event it take base class virtual function. it doesn't goes to derived class function. don't know why?
base class function like this and does not have any variable. all function are virtual.
virtual void MoveLine(POINT pt1, POINT pt2){};
virtual void DrawLine(POINT pt1, POINT pt2){};
please help.
Thanks in Advance.

Well, #define, and #if are compile time only constructs.  Technically they are processed before you program is compiled (that is why they are called preprocessor directives).  If you need to support both flavors at runtime you will need a different
approach.
Inheritance/polymorphism could be a good approach here, but I don't really understand what you are trying to do well enough to say for sure.  Based on guesses about what you want, here are some thoughts.
class GDI {public: int z;};
class OGL{public: double z;};
class M_VIEW_BASE {
virtual void MoveLine(POINT pt1, POINT pt2) = 0;
virtual void DrawLine(POINT pt1, POINT pt2) = 0;
class M_VIEW_GDI {
GDI UseThis;
void MoveLine(POINT pt1, POINT pt2) override {}
void DrawLine(POINT pt1, POINT pt2) override {}
class M_VIEW_OGL {
OGL UseThis;
void MoveLine(POINT pt1, POINT pt2) override {}
void DrawLine(POINT pt1, POINT pt2) override {}
std::unique_ptr<M_VIEW_BASE> drawBase;
enum DrawMode { DrawGdi, DrawOgl };
extern "C" __declspec(dllexport) void Init(DrawMode whichMode) {
if (drawMode == DragGdi) {
drawBase.reset(new M_VIEW_GDI);
} else if (drawMode == DrawOgl) {
drawBase.reset(new M_VIEW_OGL);
} else {
throw std::runtime_exception("whoops");
extern "C" __declspec(dllexport) void MoveLine(POINT pt1, POINT pt2) {
drawBase->MoveLine(pt1, pt2);
extern "C" __declspec(dllexport) void DrawLine(POINT pt1, POINT pt2) {
drawBase->DrawLine(pt1, pt2);

Similar Messages

  • How to use one variable as a default value for another variable?

    Hi Experts,
    Is it possible to use one variable as a default value for another variable?
    For example:
    Variable 1 = current calendar year month
    Variable 2 = mandatory input ready variable for calendar year month
    I want to use variable 1 as default value for variable 2, but also have the ability to change the month if required.
    Thanks!
    Kathryn

    u can use replacement path variable
    in that case u can replace the values of 1 variable with the another variable...
    but  u cannot do this setting
    u cannot make variable 2 as mandatory
    u cannot enter value for variable 2
    because by default it will take the value of variable 1
    u have to make follow settings
    variable 2
    name , technical name
    processing by = replacement path
    infoobject = ocalmonth
    next tab
    replaced by another variable
    variable name
    offset start , offset lenght
    save and hit okey

  • How to use one SessionInfo for many Frame

    Hi Sathish;
    thank's for your answer but How do this?
    thank you

    I use one sessionInfo on the base frame and then pass it to child forms in constructor.
    You then have to correctly set the bind names for all controls on the child forms.
    The truth is that yes, this way you loose the design facilities but I use a simple trick:
    I also have sessionInfo objects on the child forms and let the designer generate as much as I can get from it and then I adjust the code so that it uses the base sessionInfo.
    Easy uh ?

  • How to use one URL for several Oracle AS?

    Hi folks,
    how do I use one URL to access several application servers (i.e. for different applications).
    Example:
    We have one URL:
    www.test.com
    In our DMZ, wie have three application servers and one web cache:
    test1.intranet.com:7777
    test2.intranet.com:7777
    test3.intranet.com:7777
    webcache.intranet.com:8000
    One application server is no problem. In Web Cache, i just map site www.test.com:443 to AS test1.intranet.com:7777.
    But what is the correct setting, to access all three Oracle AS over one URL? I tried URL PATH Prefix. Then i am able to access all three Oracle AS, but the application server does not know the Path.
    Example for mapping:
    www.test.com:443/server2 -> test2.intranet.com:7777
    When I access www.test.com:443/server2, I get redirected to the correct AS (test2.intranet.com:7777), but the Oracle AS does not know the path /server2.
    How do I have to configure the Oracle AS?
    Thanks in advance and best regards.

    I setted up a proxy and at first glance,
    it works fine. The problem are internal links. Some links redirect to the
    machine name, which is of course not accessible from outside our dmz.
    My httpd.conf entries:
    ProxyPass /test1infra/ http://test1.intranet.com:7777/
    ProxyPassReverse /test1infra/ http://test1.intranet.com:7777/
    ProxyPass /test1mid/ http://test1.intranet.com:7778/
    ProxyPassReverse /test1mid/ http://test1.intranet.com:7778/
    When I now access (for example) www.test.com/test1infra/pls/orasso I get
    redirected to www.test.com/pls/orasso, which is another Oracle AS!
    How can I prevent my OracleAS doing this? It has to "know" that all its internal urls need a url path prefix.

  • How to use php variable for default tabbed panel

    I have a tabbed panel and with tabs labelled with the days of the week.  What I want to do is open up the tab that correspond to the current day.  I have been using the following to get the day in 3 char format:
    <?php
    $jd=cal_to_jd(CAL_GREGORIAN,date("m"),date("d"),date("Y"));
    echo(jddayofweek($jd,2));
    ?>
    What I want to do is replace the value for the default tab in the following statement with a variable that matches the day returned with a number:
    var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1", {defaultTab:1});
    Please could anyone advice?
    Regards,
    Lloyd

    Hi,
    BIND_VARIABLE is useful when you have only IN variable but in your case you have IN and OUT.
    I don't know if you use the gateway for MS SQL SERVER or HSODBC/DG4ODBC but here how you can do to call a remote procedure with bind variables:
    DECLARE
    ret integer;
    inp varchar2(255);
    outp varchar2(255);
    BEGIN
    inp :='Hello World';
    outp :='';
    ret := "dbo"."in_out_proc_test"@tg4msql( inp, outp);
    dbms_output.put_line('Input value: ' ||v_ut1||' - Output value: '||v_ut2);
    END;
    The MS SQL Server procedure belongs to the user "dbo" and the database link
    being used is tg4msql.
    The following line initilaize the out variables of the procedure with an
    empty string:
    outp :=''
    I hope it helps you.
    Regards
    Mireille

  • How to use a variable between interfaces or class?

    Hello All;
    Far by now I can say that the forum is very helpful for me. Thanks for all the people who have the time and generosity to help our problems. Thank you.
    Unfortunately I have a problem <Again :( >
    I want to use a variable in two different *.java files.
    Is it possible?
    The Variable i want to use is; int CiftSayisi
    The variable is declared in the CamCalib.Java under a button's Action Listener.
    Here is the code;
    public void actionPerformed(ActionEvent arg0) {
                        ImagePair.main(null);
                        String[] ImPath = list.getItems();                                           //Storing Items in an Array
                        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();                     //Dimensions of the Screen Storing in an object
                        int ScreenHeight = dim.height;                                           //Definition ScreenHeight
                        int ScreenWidth = dim.width;                                          //Definition ScreenWidth
                        // System.out.println(ScreenHeight);                                                    //Testing of the Dimensions
                        // System.out.println(ScreenWidth);                                                     //Testing of the Dimensions
                        int CiftSayisi = ImPath.length -1 ;
                        if (CiftSayisi == 0){
                             System.out.println("Added Images do not Construct a Pair");
                        else {
    }Now i want to use it in another java file which is ImagePair.Java in the loading part of the interface;
                 setType(Type.UTILITY);
              setTitle("Image Pair Selection");
              setResizable(false);
              setAlwaysOnTop(true);
              setBounds(100, 100, 450, 68);
              contentPane = new JPanel();
              contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
              setContentPane(contentPane);
              contentPane.setLayout(null);
              textField = new JTextField();
              textField.setBounds(61, 11, 22, 20);
              textField.setEditable(false);
              textField.setEnabled(false);
              contentPane.add(textField);
              textField.setColumns(2);I have a text field in here that i need to fill with the value of CiftSayisi
    Any help please?
    ömer kaya
    METU-GGIT
    Edited by: Ömer K. on Apr 10, 2012 12:43 AM

    I didn't bother reading the code, since you didn't format it.
    But to answer your question (if I understand it correctly), yes, it is possible to pass variables between different object instances (not from an interface specifically, since interfaces don't have members). The simplest way to pass the variable as an argument to a method or constructor. If these aren't available, you could create a static global variable, though in a multithreaded app you'd have to synchronize access.

  • SSIS: How to use one Variable as Input and Output Parameter in an Execute SQL Task

    Hello,
    i need your help,I'm working on this issue since yesterday and have no idea how to deal with it.
    As I already said in the tilte i want to start a stored procedure via a Execute SQL Task which has around 15 prameters. 10 of these should be used as input AND output value.
    As an example:
    i have three  Variable:
    var1    int        2
    var2    int     100
    var3    int     200
    the stroed procedure:
       sp_test
          @var1 int
          @var2 int output
          @var3 int output
       AS
       BEGIN
            SET @var2 = @var2 * @var1
            SET @var3 = @var3 + @var1
       END
    So in the Execute SQL Task i call the Stored Procedure as follwos:
        Exec sp_test  @var1 = ?, @var2 = ? output, @var3 = ? output
    (I use an OLE DB Connection)
    The parameter mapping is as follows:
    User::Var1        input                   numeric              0                 -1
    User::Var2        input/output         numeric              1                 -1
    User::Var3        input/output         numeric              2                 -1
    Now my problem. If i set  Var2 and Var3 as Input parameter the values are still the same after running the package. If i set them to a output value the are both Null because the procedure doesnt get any values.
    I already tried to list them a second time - like
        User::Var2        input                  numeric              1                 -1
        User::Var2        output                 numeric              1                 -1
    or i use a new variable
        User::Var2                  input                  numeric              1                 -1
        User::Var2Return        output                 numeric              1                 -1
    but i alwas get the error
    "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done."
    Has anybody an idea how I can solve this problem?
    Thanks a lot.
    Kind Regards,
    Alice

    Hi Alain,
    thx for your answer.
    I have around 15 procedures called one after the other to calculated and modify my values. Each procedure is responsible for an other but overlapping set of variables. So i thought it would be a good idea to call them one after the other with the needed variables via a execute sql task.
    So if i use a result set, how i get my stored procedure to return 10 values? I would have to use a Function instead of a procedure, wouldn't i?
    As if i have 15 procedures this would be a lot of work.
    But thanks a lot for the idea. I think an other idea would be to create one function which calls all stored procedures and returns all the calculated values as a result set, wouldn't it?.
    Kind Regards.
    Alice

  • How to use one NIC for everything and the other to allow ssh from

    Hello,
    I have two internet connexion at home:
    - a cable connection (CABLEBOX) that i use for all of my devices as it's the fastest. All my computers are connected to it using ethernet or wifi.
    - an adsl connection (ADSLBOX) that is connect to the second network card of one of my computers (MEDIABOX) only and that i want to use only to ssh that same device from the outside
    I want that specific computer to use its:
    - NIC1 to connect to the LAN and to the internet. Routing is enabled on CABLEBOX.
    - NIC2 to connect to that device from the outside using ssh. ssh-D should also work through NIC2 as i need to be able to use that computer as a proxy on some occasions. Routing is enabled on ADSLBOX and it's set to port forward the port 22 to MEDIABOX.
    Once this will be working i'd like to also route ftp connections to specific ips by NIC2.
    No firewall is set on MEDIABOX yet, i'll do it later on.
    I know basics on how to set routing rules, how to assign a specific LAN to a network card but i have a hard time on deciding which rules i should set...
    Can someone guide me?
    Thanks in advance
    Last edited by parpagnas (2013-12-03 18:31:31)

    A possible solution might be this.
    On ADSLBOX and CABLEBOX configure different subnets for the LAN, e.g.
    ADSLBOX:    192.168.1.0/24
    CABLEBOX: 192.168.2.0/24
    The MEDIABOX gets these static IPs:
    ADSL-LAN: 192.168.1.2
    CABLE-LAN: 192.168.2.2
    On the MEDIABOX, configure the two network interfaces using two routing tables.
    The ADSL-LAN routing table
    ip route add 192.168.1.0/24 dev eth0 src 192.168.1.2 table 1
    ip route add default via 192.168.1.1 table 1
    The CABLE-LAN routing table
    ip route add 192.168.2.0/24 dev eth1 src 192.168.2.2 table 2
    ip route add default via 192.168.2.1 table 2
    The main routing table
    ip route add 192.168.1.0/24 dev eth0 src 192.168.1.2
    ip route add 192.168.2.0/24 dev eth1 src 192.168.2.2
    # use the CABLE-LAN gateway as default, so general internet traffic from MEDIABOX runs over CABLEBOX
    ip route add default via 192.168.2.1
    define the lookup rules
    ip rule add from 192.168.1.2 table 1
    ip rule add from 192.168.2.2 table 2
    To test the setup:
    ip route show
    ip route show table 1
    ip route show table 2
    I don't know how to persist something like this in ArchLinux using netctl. Might require to write a special systemd unit for it. Above is a working example from a RedHat box at my company.
    Last edited by teekay (2013-12-04 07:42:22)

  • How to use one button for mltiple task?

    hi, every body,
    how do i get one button to do mitple tasks,for example
    i have one button called(+), i'd like it to do addition and get the answer,in other word:
    1-press any number, called it 1.
    2-press the (+) button to add previous number.
    3-press anthor number, called it 5.
    4-again press the (+) button to add two numbers(1+5)and show the answer(6) .
    5-again press anthor number called it 4.
    6-press the (+) button again ,to add previous result(6) to current number(4)and show the answer that is(10) and so on...

    sorry for being late here is the code
    import java.util.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.*;
    import java.io.*;
    public class Calc2 {
    private JTextField d1;
    private JFrame frame;
    private int a,s,sum;
    public static void main (String[] args) {
    Calc2 g = new Calc2();
    g.go();
    } // close main
    public void go() {
    frame = new JFrame("Simple");
    Panel mainPanel = new Panel();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Font bigFont = new Font("sanserif",Font.BOLD,24);
    d1 = new JTextField(10);
    JButton b = new JButton("+");
    b.addActionListener(new AddListener());
    mainPanel.add(d1);
    mainPanel.add(b);
    frame.getContentPane().add(BorderLayout.CENTER,mainPanel);
    frame.setSize(500,600);
    frame.setVisible(true);
    }//close go()
    public class AddListener implements ActionListener {
    public void actionPerformed(ActionEvent ev) {
    String x = d1.getText();
    s = Integer.parseInt(x);
    d1.setText("");
    d1.requestFocus();
    String z = d1.getText();
    a = Integer.parseInt(z);
    sum = a + s;
    //Now how to keep track of a sum variable, and a currentValue variable.
    d1.setText(Integer.toString(sum));
    }//close inner
    }//close class

  • How to use one certificate for two directory servers?

    Hi,
    running Sun DSEE 6.3.1 on two servers, server 1 has name ds1.example.com, server 2 has name ds2.example.com. There is a round robin DNS record ds.example.com, which alternates between:
    ds1.example.com
    ds2.example.com
    and
    ds2.example.com
    ds1.example.com
    An LDAP client connects to one of the servers over SSL using the name ds.example.com. We want to generate a certificate using the name ds.example.com and use it on both directory servers.
    If we generate a CSR using DSCC on server 1 and get back a signed certificate, the certificate can be installed correctly on server 1. However, if we use the same signed certificate on server 2 it fails with error:
    Unable to find private key for this certificate.
    Failed to add the certificate.
    Error executing the operation. The error code is 11.
    What is the correct way to generate one CSR, have it signed by a CA and then implement this signed certificate on multiple servers?
    /rolf

    From one Directory Server (ds1) generate CSR with the name ds.example.com in the request. Once you get the signed cert import it into the same server you generated CSR with. Then from ds1.example.com :
    scp -p <slapd install/instance path>/alias/* <account>@ds2.example.com:<slapd install/instance path>/alias/
    to copy the contents of the alias path to the same location on the other Directory Server. Make sure file permissions are the same.

  • How to use one wallet for both infrastructure & midtier installations?

    I have a 10.1.2.0.2 Portal installation that also includes the metadata repository & other infrastructure components on the same server. I need to configure SSL throughout Portal and I have 1 server certificate that I installed in Oracle Wallet Manager in the infrastructure home. Can I use this same certificate for the midtier without installing it in the midtier Wallet Manager?
    Thanks,
    Denise

    From one Directory Server (ds1) generate CSR with the name ds.example.com in the request. Once you get the signed cert import it into the same server you generated CSR with. Then from ds1.example.com :
    scp -p <slapd install/instance path>/alias/* <account>@ds2.example.com:<slapd install/instance path>/alias/
    to copy the contents of the alias path to the same location on the other Directory Server. Make sure file permissions are the same.

  • How to use string Variables for data provider names

    Really what I need to be able to do is insert the variable
    name in this:
    dataProvider="{chartXML2.lastResult.month.day}"
    I need to replace the "month" with a string variable name
    (i.e public var monthName = "January";)
    I also need to do the same for the categoryfield as it will
    not let me do categoryfield=$String.
    In PHP this is incredibly easy to do. You just say
    blah=$string . In fact, in PHP you can embed variable names
    everywhere. Its very powerful. For instance, in php, for the
    dataprovider issue above, i'd just do
    dataProvider="{chartXML2.lastResult.$StringName.day}"
    and it'd work just fine. Whats the syntax for doing this in
    Flex?

    You can use bracket notation. But don't. Use a reuslt handler
    to wrap the xmllist in an XMLListCollection instance variable and
    bind to that.
    Tracy

  • To use one SessionInfo for multiple frames

    how to use one SessionInfo for master frame and other frame the detail
    Thanks for your reply.

    You can instantiate the SessionInfo and other dataproducer objects in frame1 and bind them to controls in the first and second frames.
    If you plan to change/execute queries pass the sessionInfo instance to the second frame.
    Hope this helps.
    Sathish
    null

  • How to  use data function using characterstics variable for calculation on

    how to  use data function using characterstics variable for calculation on  attribute as key figure

    Hi Gayatri
    Did you not see my answer for CASE because CASE does indeed offer the use of the BETWEEN clause, but DECODE does not. Let me give you a little synopsis of DECODE.
    In its most simple form it takes 4 values and looks like this: DECODE(A, B, C, D)
    This essentially means, IF A = B THEN C ELSE D
    The trick to solving BETWEEN in a DECODE is to work out algoriths where A = B. Because we don't know how many values are between 00 and 99, although I could guess there were 100 we could of course have 100 parts in the DECODE but that would be awful. How about if we look at it another way and say this:
    IF PART_NUMBER < 'SDK00' THEN pay_amount
    ELSE IF PART_NUMBER > 'SDK99' THEN pay_AMOUNT
    ELSE pay_amount + 100
    This statement only had 2 hard coded values, but how to make DECODE work with less than? Easy, we use the LEAST function. The LEAST function takes 2 values and returns the one with the lowest value. So I use LEAST(PART_NUMBER, 'SDK00') then whenever the PART_NUMBER is lower than SDK00 it will be true. A similar situation exists for the opposite function GREATEST. Putting all of this together then, you can do this:
    DECODE(PART_NUMBER, GREATEST(PART_NUMBER, 'SDK00'), DECODE(PART_NUMBER, LEAST(PART_NUMBER, 'SDK99'), PAY_AMOUNT * 100, PAY_AMOUNT), PAY_AMOUNT)
    In English this can be read as follows:
    IF the PART_NUMBER is greater than or equal to SDK00 and the PART_NUMBER is less than or equal to SDK99 THEN PAY_AMOUNT x 100 ELSE 0
    Best wishes
    Michael

  • HT204053 Dear Support Team, every time i tried to logon Icloud its gives me wrong user name or password and at the end it show me error " This Apple ID is valid but is not an ICloud Account" then how can i use one account for same Apple ID and ICloud???

    Dear Support Team,
    Every time i tried to logon Icloud its gives me wrong user name or password and at the end it show me error " This Apple ID is valid but is not an ICloud Account" then how can i use one account for same Apple ID and ICloud?
    Thanks

    It is not possible to create a new iCloud account using a Windows machine. You must create the account using a Mac (10.7.5 or more) or an IOS device (iPhone etc). Once that is done you can sign into and use the account on your Windows machine.

Maybe you are looking for

  • When attempting to view the date track history for one employee, errors out

    Hi All When I attempt to view the date track history for one employee, it gives errors. To get the details, the navigation is : 1. Search for employee xxxxxx 2. click on Assignment button 3. click on Date Track History. 4. Receive error APP-DT-52554.

  • Iphone 5 update ios 7 then Downgrade to ios 6.1.4 lock icloud

    Me for some people you would like to iphone and they have a login iCloud timing me do not know the account and then up cannot access to be iphone

  • Public static vs private

    Hi I have 3 classes, A, B & C. I have one variable, var, that can be used in class B and C; I have declared it in class B, and passed when I create an istance of C in B. Then I need also to read its value in class A. Now the ways are two (I think ...

  • Interface Using BAPI for Uploading shipment datas

    Can any1 send me the example code for Inbound Interface using BAPI for Uploading shipment datas.please kindly send me the programs which u using with BAPI

  • Files Won't Open On Other Machines

    I have a 2 Ghz Intel Core Duo laptop running OS X Version 10.4.8 and am running Logic Express 7.2.3 (961.9). Recently I created several songs and tried to open them up in two different studios. But every attempt was unsuccessful. Each tim I got a mes