casting

Angular 2 (typescript) Cast Json to Object[]

眉间皱痕 提交于 2019-12-12 05:57:03
问题 I have a server that have a route (/users for example) that return a list on user as json. I would like in my typeScript to convert the response json to an array of my user model. For now i have something like this : user.service.ts : searchUser() : void { return this.http.get('http://127.0.0.1:3000/users/' + this.serializeUrlParam({})) .toPromise() .then(response => response.json() as User[]) .catch(); } my user.ts : export class User { infos: Object; } Where i use my service : service

“void value not ignored as it ought to be” - Qt/C++

拟墨画扇 提交于 2019-12-12 05:49:54
问题 I have this simple "interface" for some plugins I want to develop, it looks like: class TestPluginBase : public QObject { Q_OBJECT public: TestPluginBase(); qint64 returnType(){return PluginType;} protected: qint64 PluginType; }; And some other classes which implement the "interface" like: class TestPluginONE : public TestPluginBase { public: TestPluginONE() {this->PluginType =1;} qint64 returnType() {return this->PluginType;} }; Then I have another function which suppose to load different

Get variables' types at runtime in C

一世执手 提交于 2019-12-12 05:49:38
问题 Can I get in C the program variables' types those existing in a specific memory segment at runtime. C Does not recognize the error in: int k=5; float s= 3.4; k=s; printf("%d", k); I am trying to change the variables' types at runtime. 回答1: C is a static type language, you can't change a variable's type. This code: int k=5; float s= 3.4; k=s; //type conversion didn't change k 's type, k is still of type int , all it does is to convert the float value ( 3.4f ) to an int (which is 3 ), and

C convert section of char array to double

安稳与你 提交于 2019-12-12 05:49:11
问题 I want to convert a section of a char array to a double. For example I have: char in_string[] = "4014.84954"; Say I want to convert the first 40 to a double with value 40.0 . My code so far: #include <stdio.h> #include <stdlib.h> int main(int arg) { char in_string[] = "4014.84954"; int i = 0; for(i = 0; i <= sizeof(in_string); i++) { printf("%c\n", in_string[i]); printf("%f\n", atof(&in_string[i])); } } In each loop atof it converts the char array from the starting pointer I supply all the

Casting DataRow to Strongly-Typed DataRow

孤者浪人 提交于 2019-12-12 05:28:21
问题 I have a class that extends DataRow : import org.jdesktop.dataset.DataRow; public class MainDataRow extends DataRow { private MainDataTable baseDataTable; protected MainDataRow(MainDataTable dt) { super(dt); this.baseDataTable = dt; } public int getId() { return (int) super.getValue(baseDataTable.getColId()); }; public void setId(int id) { super.setValue(baseDataTable.getColId(), id); }; public int getDelta() { return (int) super.getValue(baseDataTable.getColDelta()); }; public void setDelta

Specify object type of a returned array list dynamically

↘锁芯ラ 提交于 2019-12-12 05:28:03
问题 I have following class which takes an interface and execute some functions: public class MSSQLHandler { IMSSQLStatement statement; public MSSQLHandler(IMSSQLStatement statement) { this.statement = statement; } public void invoke() throws SQLException { statement.executeStatement(); } public List<?> getDataList() throws SQLException { return statement.getDataList(); } } The interface is implemented by an abstract class: public abstract class MSSQLStatement implements IMSSQLStatement {

Calling activity method from fragment NullPointerException

霸气de小男生 提交于 2019-12-12 05:27:50
问题 I have a problem with accessing activity's method from fragment. Or anything int the activity from the fragment. Here's fragment code: public class MainFragment extends Fragment { private MainActivity ma = (MainActivity) getActivity(); public SipAudioCall call = null; public SipManager mSipManager = null; public SipProfile mSipProfile = null; public MainFragment() { // TODO Auto-generated constructor stub } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,

Is reinterpret_cast and c-style cast compatible (by C++ standard)?

末鹿安然 提交于 2019-12-12 05:15:08
问题 The C++ standards mentions that reinterpret_cast is implementation defined, and doesn't give any guarantees except that casting back (using reinterpret_cast ) to original type will result in original value passed to first. C-style casting of at least some types behaves much the same way - casting back and forth results with the same value - Currently I am working with enumerations and int s, but there are some other examples as well. While C++ standard gives those definitions for both cast

Cast a class in Java

六眼飞鱼酱① 提交于 2019-12-12 05:00:38
问题 basic casting should be MyClass mc = (MyClass)aClass that is easy but based on my program, I don't know the class name until runtime. for example, the class name could be interp_0, interp_1, interp_2, interp_3 .......#; Is there anyway in java that I could use to cast it? For now All I got is Class afterCast = Class.forName("Interp_" + countState); but what I want is ("Interp_" + countState) afterCast , not Class afterCast . Thanks for all of you who help me. It is so quick than I expected.

How Upcasting preserve derived classes's Properties? [closed]

╄→尐↘猪︶ㄣ 提交于 2019-12-12 04:57:11
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . static void Main(string[] args) { Student student = new Student() { ID = 12, Name = "Manu", LastName = "Shekar" }; Iregister x = student; Student newstudent = x as Student; //Console.WriteLine(x.LastName); //Uncommenting this shows compilation error Console.WriteLine(newstudent