method-call

How to pass arguments to a method loaded from a static library in CPP

淺唱寂寞╮ 提交于 2019-12-04 15:40:49
I'm trying to write a program to use a static library of a C++ code into another C++ code. The first C++ code is hello.cpp : #include <iostream> #include <string.h> using namespace std; extern "C" void say_hello(const char* name) { cout << "Hello " << name << "!\n"; } int main(){ return 0; } The I made a static library from this code, hello.a , using this command: g++ -o hello.a -static -fPIC hello.cpp -ldl Here's the second C++ code to use the library, say_hello.cpp : #include <iostream> #include <string> #include <dlfcn.h> using namespace std; int main(){ void* handle = dlopen("./hello.a",

How to pass objects to keywords in robot framework?

六月ゝ 毕业季﹏ 提交于 2019-12-04 12:18:43
问题 I have a python class MyClass written in file MyClass.py : class MyClass(object): def __init__(self): self.myvar = list() def setvar(self, val): self.myvar = val def mymethod(self): return self.myvar I have imported in Robot Framework as below: Library MyClass WITH NAME my_component I also have a keyword which call a method of objects which are passed to it: testing component [Arguments] ${cmp} log to console ************* ${cmp} ${result} = ${cmp}.mymethod I have multiple objects

C# & generics - why is method in base class called instead of new method in derived class?

一世执手 提交于 2019-12-04 05:32:36
If the generic type argument (of either a calling class or calling method) is constrained with where T : Base the new method in T == Derived is not called, instead the method in Base is called. Why is the type T ignored for method call even though it should be known before run time? Update : BUT, when the constraint is using an interface like where T : IBase the method in Base class is called (not the method in interface, which is also impossible). So that means the system actually is able to detect the types that far and go beyond the type constraint! Then why doesn't it go beyond the type

Prevent strings from being interpreted as a file handle

折月煮酒 提交于 2019-12-03 10:40:47
Perl has the feature that strings named like a file handle are taken to be a filehandle: # let this be some nice class I wrote package Input { sub awesome { ... } } So when we do Input->awesome or extra-careful: 'Input'->awesome , the method will get called. Unless: # now somewhere far, far away, in package main, somebody does this: open Input, "<&", \*STDIN or die $!; # normally we'd open to a file This code doesn't even have to be executed, but only be seen by the parser in order to have Perl interpret the string 'Input' as a file handle from now on. Therefore, a method call 'Input'->awesome

C++ method call and type scope resolution ambiguity

感情迁移 提交于 2019-12-03 05:53:53
I hope the title actually describes what I wanted to ask... I wrote a piece of code that compiles with gcc and works as I intended. However, it does not compile with llvm and the code executes differently when compiled with icc! Here is an example of the problem: #include <iostream> using std::cout; using std::endl; class A { public: virtual void foo() { cout << "A::foo()" << endl; } }; class B : public A { public: typedef A base; virtual void foo() { cout << "B::foo()" << endl; } }; int main() { typedef B base; base* bp = new B(); bp->base::foo(); } gcc output: A::foo() icc output: B::foo()

Passing single object vs. passing multiple parameters

[亡魂溺海] 提交于 2019-12-03 00:15:14
Suppose I have the following Class A { Foo getFoo(); Bar getBar(); Baz getBaz(); } And I need to define a function doStuff that uses Foo , Bar , Baz of one object and does some stuff I'm struggling between which method of implementing doStuff is better (suppose it would be undesirable to place doStuff inside class A ) Method A void doStuff(Foo foo, Bar bar, Baz baz) { //some operation } or Method B void doStuff(A a) { Foo foo = a.getFoo(); Bar bar = a.getBar(); Baz baz = a.getBaz(); //some operation } To my limited knowledge, (+ pros, - cons) Method A +It is clear exactly what parameters

How can I call the action method inside the MVCPortlet class onclick of the Submit button

走远了吗. 提交于 2019-12-02 21:07:35
问题 I am using Liferay 6 for development. I have added JQuery support to Liferay this way inside the file liferay-portlet.xml file <header-portlet-javascript>https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js</header-portlet-javascript> <header-portlet-javascript>https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.15/jquery-ui.min.js</header-portlet-javascript> Now I have a form with Username and password as shown below: <form> <div> <input class="default-value" type="text" name=

How can I call the action method inside the MVCPortlet class onclick of the Submit button

女生的网名这么多〃 提交于 2019-12-02 12:45:10
I am using Liferay 6 for development. I have added JQuery support to Liferay this way inside the file liferay-portlet.xml file <header-portlet-javascript>https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js</header-portlet-javascript> <header-portlet-javascript>https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.15/jquery-ui.min.js</header-portlet-javascript> Now I have a form with Username and password as shown below: <form> <div> <input class="default-value" type="text" name="Name" value="Name" /> <input class="default-value" type="text" name="Password" value="Password" /> </div>

How to enforce a method call (in the base class) when overriding method is invoked?

末鹿安然 提交于 2019-12-01 17:42:12
I have this situation that when AbstractMethod method is invoked from ImplementClass I want to enforce that MustBeCalled method in the AbstractClass is invoked. I’ve never come across this situation before. Thank you! public abstract class AbstractClass { public abstract void AbstractMethod(); public void MustBeCalled() { //this must be called when AbstractMethod is invoked } } public class ImplementClass : AbstractClass { public override void AbstractMethod() { //when called, base.MustBeCalled() must be called. //how can i enforce this? } } An option would be to have the Abstract class do the

Method is not called inside the action listener method in java swing

怎甘沉沦 提交于 2019-12-01 14:52:34
I have to call a method inside the java swing actionperformed method. But when I click the button nothing happens. How to solve this problem? private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { hellocalled(); } } You need to add action listener to your button in order to respond to click event: Button b = new Button(); b.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt){ jButton1ActionPerformed(evt); // call the method jButton1ActionPerformed // or you can call the one you have defined `hellocalled();` here } } } 来源: https://stackoverflow