Search Results

Search found 45098 results on 1804 pages for 'public static void'.

Page 14/1804 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Serving CSS from a static domain

    - by Saif Bechan
    I want to serve my css and images from a static cookieless domain. Now my problem is how to point to the images from within my css files. I don't want to program my domain hard within the css file, for example: http://static.com/image.png I would rather have a variable pointing to the the image, so it works for every static domain i use. What is the best way for achieving this. Should i run the whole css file trough php and add the static domain in front of all the png references. A downside in this is that i have to place the whole css in html. Or is there another more optimized way of doing this.

    Read the article

  • static const C++ class member initialized gives a duplicate symbol error when linking

    - by Petruza
    I have a class which has a static const array, it has to be initialized outside the class: class foo{ static const int array[3]; }; const int foo::array[3] = { 1, 2, 3 }; But then I get a duplicate symbol foo::array in foo.o and main.o foo.o hold the foo class, and main.o holds main() and uses instances of foo. How can I share this static const array between all instances of foo? I mean, that's the idea of a static member.

    Read the article

  • What's static function for in c?

    - by user198729
    I only see static methods by which we don't need to instantiate a class to call the method. What's the purpose of a static function? static GtkWidget * create_bbox (gint horizontal, char *title, gint spacing, gint layout) { ... }

    Read the article

  • Java: when to use static methods

    - by KP65
    Hello, I am wondering when to use static methods? Say If i have a class with a few getters and setters, a method or two, and i want those methods only to be invokable on an instance object of the class. Does this mean i should use a static method? e.g Obj x = new Obj(); x.someMethod or Obj.someMethod (is this the static way?) I'm rather confused!

    Read the article

  • Why can't you call a non-static method from a static method?

    - by VoodooChild
    I have a static method [Method1] in my class, which calls another method [Method2] in the same class and is not a static method. But this is a no-no. I get this error: An object reference is required for the non-static field, method, or property "ClassName.MethodName()" Can someone please briefly describe why? including other things that might be related to this.

    Read the article

  • static, define, and const in C

    - by yCalleecharan
    Hi, I've read that static variables are used inside function when one doesn't want the variable value to change/initialize each time the function is called. But what about defining a variable static in the main program before "main" e.g. #include <stdio.h> static double m = 30000; int main(void) { value = m * 2 + 3; } Here the variable m has a constant value that won't get modified later in the main program. In the same line of thought what difference does it make to have these instead of using the static definition: const double m = 30000; or #define m 30000 //m or M and then making sure here to use double operations in the main code so as to convert m to the right data type. Thanks a lot...

    Read the article

  • Static variables in C and C++

    - by Naveen
    Is there any difference between a variable declared as static outside any function between C and C++. I read that static means file scope and the variables will not be accessible outside the file. I also read that in C, global variables are static . So does that mean that global variables in C can not be accessed in another file?

    Read the article

  • Javascript - cannot make static reference to non-static function ....

    - by Ankur
    I am making a reference to the Javascript function splice() on an array and I get the error: "Cannot make a static reference to the non-static function splice()" What's going on - how is this a static reference, aren't I referencing an instance of an Array class and its method - how is that static? $(document).ready( function() { var queryPreds = new Array(); var queryObjs = new Array(); function remFromQuery(predicate) { for(var i=0; i<arrayName.length;i++ ) { if(queryPreds[i]==predicate) queryPreds.splice(i,1); queryObjs.splice(i,1); } } }

    Read the article

  • Would you make this method Static or not?

    - by Adam Drummond
    During a code review I presented a method quickly to the team that I had made static and one person agreed that there was no reason for it to not be static and a person disagreed saying that he would not make it static because it wasn't necessary and just to be on the safe side for future modifications and testing. So I did quite a bit of research and obviously it's a specialized case but I would like to know what you would do in this situation and why? (Its basically a helper method I call from a few different methods, a very low traffic page. More for my knowledge and learning on Static.) private IEnumerable<Category> GetCategoryByID(int id, Context context) { var categoryQuery = from selectAllProc in context.SelectAll_sp() where selectAllProc.CategoryID == id select selectAllProc; return categoryQuery; }

    Read the article

  • CodeIgniter static class question

    - by Josh K
    If I would like to have several static methods in my models so I can say User::get_registered_users() and have it do something like public static function get_registered_users() { $sql = "SELECT * FROM `users` WHERE `is_registered` = 0"; $this->db->query($sql); // etc... } Is it possible to access the $this->db object or create a new one for a static method?

    Read the article

  • How to free static member variable in C++?

    - by user299831
    Can anybody explain how to free memory of a static member Variable? In my understanding it can only be freed if all the instances of the class are destroyed. I am a little bit helpless at this point... Some Code to explain it: class ball { private: static SDL_Surface *ball_image; }; //FIXME: how to free static Variable? SDL_Surface* ball::ball_image = SDL_LoadBMP("ball.bmp");

    Read the article

  • C++ static virtual members?

    - by cvb
    Is it possible in C++ to have a member function that is both static and virtual? Apperantly, there isn't a straight-forward way to do it (static virtual member(); is a complie error), but at least a way to acheive the same effect? I.E: struct Object { struct TypeInformation; static virtual const TypeInformation &GetTypeInformation() const; }; struct SomeObject : public Object { static virtual const TypeInformation &GetTypeInformation() const; }; It makes sence to use GetTypeInformation() both on an instance (object->GetTypeInformation()) and on a class (SomeObject::GetTypeInformation()), which can be useful for comparsions and vital for templates. The only ways I can think of involves writing two functions / a function and a constant, per class, or use macros. Any other solutions?

    Read the article

  • Make methods that do not depend on instance fields, static?

    - by m3th0dman
    Recently I started programming in Groovy for a integration testing framework, for a Java project. I use Intellij IDEA with Groovy plug-in and I am surprised to see as a warning for all the methods that are non-static and do not depend on any instance fields. In Java, however, this is not an issue (at least from IDE's point of view). Should all methods that do not depend onto any instance fields be transformed into static functions? If true, is this specific to Groovy or it is available for OOP in general? And why?

    Read the article

  • Why does this static field always get initialized over-eagerly?

    - by TheSilverBullet
    I am looking at this excellent article from Jon Skeet. While executing the demo code, Jon Skeet says that we can expect three different kinds of behaviours. To quote that article: The runtime could decide to run the type initializer on loading the assembly to start with... Or perhaps it will run it when the static method is first run... Or even wait until the field is first accessed... When I try this out (on framework 4), I always get the first result. That is, the static method is initialized before the assembly is loaded. I have tried running this multiple times and get the same result. (I tried both the debug and release versions) Why is this so? Am I missing something?

    Read the article

  • C#4: Why does this static field always get initialized over-eagerly?

    - by TheSilverBullet
    I am looking at this excellent article from Jon Skeet at this location: http://csharpindepth.com/Articles/General/Beforefieldinit.aspx While executing the demo code, Jon Skeet says that we can expect three different kinds of behaviours. To quote that article: The runtime could decide to run the type initializer on loading the assembly to start with... Or perhaps it will run it when the static method is first run... Or even wait until the field is first accessed... When I try this out (on framework 4), I always get the first result. That is, the static method is initialized before the assembly is loaded. I have tried running this multiple times and get the same result. (I tried both the debug and release versions) Why is this so? Am I missing something?

    Read the article

  • What is the difference between all-static-methods and applying a singleton pattern?

    - by shahensha
    I am making a database to store information about the users of my website (I am using stuts2 and hence Java EE technology). For the database I'll be making a DBManager. Should I apply singleton pattern here or rather make all it's methods static? I will be using this DBManager for basic things like adding, deleting and updating User profiles. Along with it, I'll use for all other querying purposes, for instance to find out whether a username already exists and to get all users for administrative purposes and stuff like that. My questions What is the benefit of singleton pattern? Which thing is most apt here? All static methods or a singleton pattern? Please compare both of them. regards shahensha P.S. The database is bigger than this. Here I am talking only about the tables which I'll be using for storing User Information.

    Read the article

  • Requriing static class setter to be called before Constructor, bad design?

    - by roverred
    I have a class, say Foo, and every instance of Foo will need and contain the same List object, myList. Since every class instance will share the same List Object, I thought it would be good to make myList static and use a static function to set myList before the constructor is called. I was wondering if this was bad, because this requires the setter to be called before the constructor. If the person doesn't, the program will crash. Alternative way would be passing myList every time. Thanks.

    Read the article

  • What is the difference between all-static-methods and applying a singleton pattern?

    - by shahensha
    I am making a database to store information about the users of my website (I am using stuts2 and hence Java EE technology). For the database I'll be making a DBManager. Should I apply singleton pattern here or rather make all it's methods static? I will be using this DBManager for basic things like adding, deleting and updating User profiles. Along with it, I'll use for all other querying purposes, for instance to find out whether a username already exists and to get all users for administrative purposes and stuff like that. My questions What is the benefit of singleton pattern? Which thing is most apt here? All static methods or a singleton pattern? Please compare both of them. P.S. The database is bigger than this. Here I am talking only about the tables which I'll be using for storing User Information.

    Read the article

  • Hide public method used to help test a .NET assembly

    - by ChrisW
    I have a .NET assembly, to be released. Its release build includes: A public, documented API of methods which people are supposed to use A public but undocumented API of other methods, which exist only in order to help test the assembly, and which people are not supposed to use The assembly to be released is a custom control, not an application. To regression-test it, I run it in a testing framework/application, which uses (in addition to the public/documented API) some advanced/undocumented methods which are exported from the control. For the public methods which I don't want people to use, I excluded them from the documentation using the <exclude> tag (supported by the Sandcastle Help File Builder), and the [EditorBrowsable] attribute, for example like this: /// <summary> /// Gets a <see cref="IEditorTransaction"/> instance, which helps /// to combine several DOM edits into a single transaction, which /// can be undone and redone as if they were a single, atomic operation. /// </summary> /// <returns>A <see cref="IEditorTransaction"/> instance.</returns> IEditorTransaction createEditorTransaction(); /// <exclude/> [EditorBrowsable(EditorBrowsableState.Never)] void debugDumpBlocks(TextWriter output); This successfully removes the method from the API documentation, and from Intellisense. However, if in a sample application program I right-click on an instance of the interface to see its definition in the metadata, I can still see the method, and the [EditorBrowsable] attribute as well, for example: // Summary: // Gets a ModelText.ModelDom.Nodes.IEditorTransaction instance, which helps // to combine several DOM edits into a single transaction, which can be undone // and redone as if they were a single, atomic operation. // // Returns: // A ModelText.ModelDom.Nodes.IEditorTransaction instance. IEditorTransaction createEditorTransaction(); // [EditorBrowsable(EditorBrowsableState.Never)] void debugDumpBlocks(TextWriter output); Questions: Is there a way to hide a public method, even from the meta data? If not then instead, for this scenario, would you recommend making the methods internal and using the InternalsVisibleTo attribute? Or would you recommend some other way, and if so what and why? Thank you.

    Read the article

  • Apache - Serving static files from different subdomain + machine

    - by rubayeet
    Here's the scenario A site is running on this domain - www.someserver.com I'm going to host subdomain.someserver.com on my machine. Let's say all the image files are under the directory 'img'. I don't want to copy all their images to my machine. So what should be the Apache directive(s) that'll map the request for an image, like http://subdomain.someserver.com/img/image.png to http://www.someserver.com/img/image.png

    Read the article

  • Static Routes and the Routing Table

    - by TheD
    This is very much a learning question if someone would be happy to explain a couple of concepts. My question is - the default routing table that exists in, in my case, a default Windows 7 install, what do each of the routes in the table do? Here is a screenshot: The 10.128.4.0 is just a route I've added while messing. I understand from a question I posted on Superuser the first route is just a default route that will route all traffic for any IP to my default gateway on my Interface in use. But what about the others? And how would the routing table handle a machine with multiple NIC's, perhaps connected to two different networks, or maybe even two NIC's on the same network so a VM can have a physical Network card instead of each VM sharing the hosts. Thanks!

    Read the article

  • Static Route Qestion

    - by mrlayance
    I have a Wan simulator between 2 networks. I can ping both networks from the wan simulator, but I can not ping from one network to the other. testr01 Fa0/0 10.0.0.1/24 FA0/1 192.168.0.1/30 | | Wan Sim 2 nics Eth0 192.168.0.2/30 | Eth1 192.168.1.2/30 | | testr02 Fa0/1 192.168.1.1/30 Fa0/0 10.1.0.2/24 I can not figure out what type of routes I need. On the route? On the Server? I guess all 10. traffic to the Fa0/0 ports? Thanks

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >