Posts

Showing posts with the label constructor

Why is std::string and std::vector not being passed to my constructor how I would expect? [duplicate]

Why is std::string and std::vector not being passed to my constructor how I would expect? [duplicate] This question already has an answer here: This is my error when trying to compile: Undefined symbols for architecture x86_64: "Model::Model(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<int, std::__1::allocator<int> >)", referenced from: ____C_A_T_C_H____T_E_S_T____4() in tests.cpp.o I have read that std::string is a typedef of std::basic_string and I'm guess that std::vector is a typedef of... std::vector and std::allocator? or something... Anyway. I have a Settings class that holds my settings and a Model class that contains my model. The code I am attempting to run is as below, and I am unable to compile it. the issue is with it not recognising my model constructor. Settings s = Settings("../config/settings.json"); std::string mf = s.get_model_file(); std::vector<in...

Javascript new array prototype in new object constructor

Javascript new array prototype in new object constructor If I do: Array.prototype.test = "test" Array.prototype.t = function() {return "hello"} Every new Array will have the property test and the method t . Array test t How can I do the same without affecting all Arrays? Like: Names = function(arr){ // Contacts constructor must be the same of Array // but add the property test and the function t } z=new Names(["john","andrew"]) So that z.test will return "test" and z.t() will return "hello" ? (but Array.test and Array.t would stay undefined ) z.test "test" z.t() "hello" Array.test Array.t undefined I explain better: Array.prototype.t="test"; Array.prototype.test = function(){ return "hello";} z=new Array("john", "andrew") console.log(z); But this affects ALL arrays. I want the same but with a new constructor Names that inherits Array constructor. ...

c# UserControl constructor don't throws exceptions as expected

c# UserControl constructor don't throws exceptions as expected This is my WinForm solution entry point in Program.cs: try { Application.Run(new MainForm()); } catch (Exception e) { Log.error(e.ToString()); ErrorHandlerForm abend = new ErrorHandlerForm(e); abend.ShowDialog(); } It works fine, every exception thrown in my solution is gracefully handled! But today I found an issue: My program don't catch exceptions that occurs in UserControls construstors! It simply crash to windows with the ugly system prompt (or it shows the error in the VisualStudio if i am in debug mode). I don't understand this behaviour and I have no idea how to fix it, I want to catch those exception in my catch block. what error do you get in Visual studio when in debug mode ? – Prany Jul 1 at 17:13 ...