Search Results

Search found 11178 results on 448 pages for 'syntax checking'.

Page 68/448 | < Previous Page | 64 65 66 67 68 69 70 71 72 73 74 75  | Next Page >

  • Ninject: Singleton binding syntax?

    - by Rosarch
    I'm using Ninject 2.0 for the .Net 3.5 framework. I'm having difficulty with singleton binding. I have a class UserInputReader which implements IInputReader. I only want one instance of this class to ever be created. public class MasterEngineModule : NinjectModule { public override void Load() { // using this line and not the other two makes it work //Bind<IInputReader>().ToMethod(context => new UserInputReader(Constants.DEFAULT_KEY_MAPPING)); Bind<IInputReader>().To<UserInputReader>(); Bind<UserInputReader>().ToSelf().InSingletonScope(); } } static void Main(string[] args) { IKernel ninject = new StandardKernel(new MasterEngineModule()); MasterEngine game = ninject.Get<MasterEngine>(); game.Run(); } public sealed class UserInputReader : IInputReader { public static readonly IInputReader Instance = new UserInputReader(Constants.DEFAULT_KEY_MAPPING); // ... public UserInputReader(IDictionary<ActionInputType, Keys> keyMapping) { this.keyMapping = keyMapping; } } If I make that constructor private, it breaks. What am I doing wrong here?

    Read the article

  • Template Syntax in C++

    - by Crystal
    I don't understand templates really and was trying to run a simple find the minimum for ints, doubles, chars. First question, why is template<typename T> sometimes used, and other times template<>? Second question, I do not know what I am doing wrong with the following code below: #include <iostream> template <typename T> T minimum(T arg1, T arg2) { return arg1 < arg2 ? arg1 : arg2; } template <typename T> // first I tried template <> instd of above, but wasn't sure the difference T minimum<const char *>(const char *arg1, const char *arg2) { return strcmp(arg1, arg2) ? arg2 : arg1; } int main() { std::cout << minimum<int>(4, 2) << '\n'; std::cout << minimum<double>(2.2, -56.7) << '\n'; std::cout << minimum(2.2, 2) << '\n'; } Compile Errors: error C2768: 'minimum' : illegal use of explicit template arguments error C2783: 'T minimum(const char *,const char *)' : could not deduce template argument for 'T' : see declaration of 'minimum' : error C2782: 'T minimum(T,T)' : template parameter 'T' is ambiguous : see declaration of 'minimum' Third, in getting familiar with separating .h and .cpp files, if I wanted this minimum() function to be a static function of my class, but it was the only function in that class, would I have to have a template class as well? I originally tried doing it that way instead of having it all in one file and I got some compile errors as well that I can't remember right now and was unsure how I would do that. Thanks!

    Read the article

  • What does L == 2 mean in MATLAB?

    - by Matlaber
    BW = logical([1 1 1 0 0 0 0 0 1 1 1 0 1 1 0 0 1 1 1 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 1 0 0 0 1 0 1 1 1 0 0 0 1 0 1 1 1 0 0 1 1 0 1 1 1 0 0 0 0 0]); L = bwlabel(BW,4); [r,c] = find(L == 2); How can a matrix been compared with scalar?

    Read the article

  • C# Get/Set Syntax Usage

    - by RoR
    These are declarations for a Person class. protected int ID { get; set; } protected string Title { get; set; } protected string Description { get; set; } protected TimeSpan jobLength { get; set; } How do I go about using the get/set? In main, I instantiate a Person Tom = new Person(); How does Tom.set/get?? I am use to doing C++ style where you just write out the int getAge() and void setAge() functions. But in C# there are shortcuts handling get and set?

    Read the article

  • "...redeclared as different kind of symbol"?

    - by CodeNewb
    #include <stdio.h> #include <math.h> double integrateF(double low, double high) { double low = 0; double high = 20; double delta_x=0; double x, ans; double s = 1/2*exp((-x*x)/2); for(x=low;x<=high;x++) delta_x = x+delta_x; ans = delta_x*s; return ans; } It says that low and high are "redeclared as different type of symbol" and I don't know what that means. Basically, all I'm doing here (READ: trying) is integrating from low (which I set to 0) to high (20) to find the Riemann sum. The for loop looks kinda trippy too...I'm so lost.

    Read the article

  • strange(?) module import syntax

    - by morpheous
    I've come across the following code in a Python script from pprint import pprint why not simply import pprint? Unless the module pprint contains a function called pprint which is being aliased as pprint (surely, this must be the definition of madness?)

    Read the article

  • What is the "x = x || {}" technique in JavaScript - and how does it affect this IIFE?

    - by Micky Hulse
    First, a pseudo code example: ;(function(foo){ foo.init = function(baz) { ... } foo.other = function() { ... } return foo; }(window.FOO = window.FOO || {})); Called like so: FOO.init(); My question: What is the technical name/description of: window.FOO = window.FOO || {}? I understand what the code does... See below for my reason(s) for asking. Reason for asking: I'm calling the passed in global like so: ;(function(foo){ ... foo vs. FOO, anyone else potentially confused? ... }(window.FOO = window.FOO || {})); ... but I just don't like calling that lowercase "foo", considering that the global is called capitalized FOO... It just seems confusing. If I knew the technical name of this technique, I could say: ;(function(technicalname){ ... do something with technicalname, not to be confused with FOO ... }(window.FOO = window.FOO || {})); I've seen a recent (awesome) example where they called it "exports": ;(function(exports){ ... }(window.Lib = window.Lib || {})); I guess I'm just trying to standardize my coding conventions... I'd like to learn what the pros do and how they think (that's why I'm asking here)!

    Read the article

  • jQuery syntax for changing the value of a table cell

    - by cf_PhillipSenn
    I have a table where every row has a unique id. The last table cell has class="status" where I want to show the user the result of their action. In my $.ajax call, I have: ,success: function(result){ $('tr#'+result).td('.status').text('Updated'); }; result is the id of the row that was updated. It's just throwing an error message that says $( and that's all.

    Read the article

  • C++, strange behavior reusing variable name

    - by aaa
    hello. I have following snippet: { double scale = 3; // not used? { double scale = 4*scale; // what is RHS scale? for (...) { // scale is 0 here, using g++ } } } moreover, g++ reports first scale is not used. how is second scale initialize? What should be correct behavior? thanks

    Read the article

  • C# Why does calling an interface member from a class generate an error?

    - by Jack
    So I have an interface: interface IFoo { int Bar(); int this[int i] {get; set;} } And a class that derives from it class Foo : IFoo { public int IFoo.Bar() { //Implementation { public int IFoo.this[int i] { //Implementation } } Now, I try to do this: var fooey = new Foo(); int i = Fooey.Bar(); or this: int i = Fooey[4]; I would expect these to work properly. However, the compiler generates an error as if such members don't exist. Why is that? I am aware I can cast Foo as IFoo, but I am also aware that casting is costly to performance, which is often the reason to use interfaces in the first place. EDIT 1: These are the errors generated 'Foo' does not contain a definition for 'Bar' and no extension method 'Bar' accepting a first argument of type 'Foo' could be found (are you missing a using directive or an assembly reference?) "Cannot apply indexing to an expression of type 'Foo'"

    Read the article

  • Javascript syntax for abbreviating repeated access to same identifier

    - by yongjieli
    Hi all I wanted to ask if there is a formal way of describing the following code, whereby we can access the same object repeatedly without re-typing the object's identifier: myObj.render(1).render(2).print(); I didn't know how to describe it when trying to form a question; I wanted to know whether or not something like this is possible in javascript, I know that I can do it in VB: myObj.render(1) if(foo == 'bar') .render(2) .print(); Thanks!

    Read the article

  • why does twitter use the !function syntax in their embed code

    - by samccone
    I was looking at twitters embed code and saw that they are using !function ... while i know that this evaluates to false I was wondering what the point of it was. thoughts? !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");

    Read the article

  • What does @@variable mean in Ruby?

    - by Andrew
    What are Ruby variables preceded with double at signs (@@)? My understanding of a variable preceded with an at sign is that it is an instance variable, like this in PHP: PHP version class Person { public $name; public function setName($name) { $this->name = $name; } public function getName() { return $this->name; } } Ruby equivalent class Person def set_name(name) @name = name end def get_name() @name end end What does the double at sign @@ mean, and how does it differ from a single at sign?

    Read the article

  • Why cant i use the field user in SQL Server 8?

    - by acidzombie24
    Maybe not literally but the query below gets an error near user. If i change it to userZ it works. WHY can i not use that name? Is there a way to specific its a field instead of a keyword? (or whatever it is) create table Post2 ( id INTEGER PRIMARY KEY NOT NULL, title nvarchar(max) NOT NULL, body nvarchar(max) NOT NULL, user integer REFERENCES Post1(id));

    Read the article

< Previous Page | 64 65 66 67 68 69 70 71 72 73 74 75  | Next Page >