Search Results

Search found 19441 results on 778 pages for 'static libraries'.

Page 1/778 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Access static method from non static class possible in java and not in c#

    - by sagar_kool
    Access static method from non static class with object. It is not possible in C#. Where it is done by JAVA. How it works? example of java /** * Access static member of the class through object. */ import java.io.*; class StaticMemberClass { // Declare a static method. public static void staticDisplay() { System.out.println("This is static method."); } // Declare a non static method. public void nonStaticDisplay() { System.out.println("This is non static method."); } } class StaticAccessByObject { public static void main(String[] args) throws IOException { // call a static member only by class name. StaticMemberClass.staticDisplay(); // Create object of StaticMemberClass class. StaticMemberClass obj = new StaticMemberClass(); // call a static member only by object. obj.staticDisplay(); // accessing non static method through object. obj.nonStaticDisplay(); } } Output of the program: This is static method. This is static method. This is non static method. How to do this in C#? thanks in advance..

    Read the article

  • Static and Non Static Method Intercall in Java

    - by Vishal
    I am clearing my concepts on Java. My knowledge about Java is on far begineer side, so kindly bear with me. I am trying to understand static method and non static method intercalls. I know -- Static method can call another static method simply by its name within same class. Static method can call another non staic method of same class only after creating instance of the class. Non static method can call another static method of same class simply by way of classname.methodname - No sure if this correct ? My Question is about non static method call to another non staic method of same class. In class declaration, when we declare all methods, can we call another non static method of same class from a non static class ? Please explain with example. Thank you.

    Read the article

  • Java: static-non-static-this problem

    - by HH
    $ javac TestFilter.java TestFilter.java:19: non-static variable this cannot be referenced from a static context for(File f : file.listFiles(this.filterFiles)){ ^ 1 error $ sed -i 's@this@TestFilter@g' TestFilter.java $ javac TestFilter.java $ java TestFilter file1 file2 file3 TestFilter.java import java.io.*; import java.util.*; public class TestFilter { private static final FileFilter filterFiles; // STATIC! static{ filterFiles = new FileFilter() { // Not Static below. When static, an error: // "accept(java.io.File) in cannot implement // accept(java.io.File) in java.io.FileFilter; // overriding method is static" // // I tried to solve by the change the problem at the bottom. public boolean accept(File file) { return file.isFile(); } }; } // STATIC! public static void main(String[] args){ HashSet<File> files = new HashSet<File>(); File file = new File("."); // IT DID NOT WORK WITH "This" but with "TestFilter". // Why do I get the error with "This" but not with "TestFilter"? for(File f : file.listFiles(TestFilter.filterFiles)){ System.out.println(f.getName()); files.add(f); } } }

    Read the article

  • trouble accessing non-static functions from static functions in AS3

    - by Dogmatixed
    I have a class containing, among other things, a drop down menu. With the aim of saving space, and since the contents of the menu will never change, I've made a static DataProvider for the whole class that populates each instances menu. I was hoping to populate the list with actual functions like so: tmpArr.push({label:"Details...", funct:openDetailsMenu, args:""}); and then assign tmpArr to the DataProvider. Because the DataProvider is static the function that contains that code also needs to be static, but the functions in the array are non-static. At first it didn't seem like a problem, because when the user clicks on a menu item the drop down menu can call a non-static "executeFunction(funct, args)" on its parent. However, when I try to compile, the static function setting up the DataProvider it can't find the non-static functions being passed. If the compiler would just trust me the code would work fine! The simple solution is to just pass strings and use a switch statement to call functions based on that, but that's big, ugly, inelegant, and difficult to maintain, especially if something inherits from this class. The simpler solution is to just make the DataProvider non-static, but I'm wondering if anyone else has a good way of dealing with this? Making the static function able to see its non-static brethren? Thanks.

    Read the article

  • Static class vs Singleton class in C# [closed]

    - by Floradu88
    Possible Duplicate: What is the difference between all-static-methods and applying a singleton pattern? I need to make a decision for a project I'm working of whether to use static or singleton. After reading an article like this I am inclined to use singleton. What is better to use static class or singleton? Edit 1 : Client Server Desktop Application. Please provide code oriented solutions.

    Read the article

  • C++: Retriving values of static const variables at a constructor of a static variable

    - by gilbertc
    I understand that the code below would result segmentation fault because at the cstr of A, B::SYMBOL was not initialized yet. But why? In reality, A is an object that serves as a map that maps the SYMBOLs of classes like B to their respective IDs. C holds this map(A) static-ly such that it can provide the mapping as a class function. The primary function of A is to serve as a map for C that initializes itself at startup. How should I be able to do that without segmentation fault, provided that I can still use B::ID and B::SYMBOL in the code (no #define pls)? Thanks! Gil. class A { public: A() { std::cout<<B::ID<<std::endl; std::cout<<B::SYMBOL<<std::endl; } }; class B { public: static const int ID; static const std::string SYMBOL; } const int B::ID = 1; const std::string B::SYMBOL = "B"; class C { public: static A s_A; }; A C::s_A; int main(int c, char** p) { }

    Read the article

  • How do you find libraries(C++) in Ubuntu?

    - by Bora George
    Sorry this is such a beginner question, but I've recently begun programming with C++ on Ubuntu 12.10 and I've installed a few libraries I need to work with, for example PCL and I can't find them to add them to my project, I'm using QTcreator as the IDE and qmake which comes with it. For example with PCL I followed the instructions on their site: sudo add-apt-repository ppa:v-launchpad-jochen-sprickerhof-de/pcl sudo apt-get update sudo apt-get install libpcl-all And as no problems occurred I have to assume they are correctly installed. Most of the tutorial dealing with adding external libraries I've found on the web assume you're on windows and know where you downloaded the library. Since I don't have experience with adding external libraries in C++, could someone please tell me in what file, if there is one, are libraries installed by default in Ubuntu? What is the extension of these library files? Is there a script/command which can help detect a library or all the libraries installed?

    Read the article

  • Questions about linking libraries in C

    - by james
    I am learning C (still very much a beginner) on Linux using the GCC compiler. I have noticed that some libraries, such as the library used with the math.h header, need to be linked in manually when included. I have been linking in the libraries using various flags of the form -l[library-name], such as -lm for the above-mentioned math library. However, after switching from the command line and/or Geany to Code::Blocks, I noticed that Code::Blocks uses g++ to compile the programs instead of the gcc that I am used to (even though the project is definitely specified as C). Also, Code::Blocks does not require the libraries to be manually linked in when compiling - libraries such as the math library just work. I have two questions: Firstly, is it "bad" to compile C programs with the g++ compiler? So far it seems to work, but after all, C++ is not C and I am quite sure that the g++ compiler is meant for C++. Secondly, is it the g++ compiler that is doing the automatic linking of the libraries in Code::Blocks?

    Read the article

  • Fake ISAPI Handler to serve static files with extention that are rewritted by url rewriter

    - by developerit
    Introduction I often map html extention to the asp.net dll in order to use url rewritter with .html extentions. Recently, in the new version of www.nouvelair.ca, we renamed all urls to end with .html. This works great, but failed when we used FCK Editor. Static html files would not get serve because we mapped the html extension to the .NET Framework. We can we do to to use .html extension with our rewritter but still want to use IIS behavior with static html files. Analysis I thought that this could be resolve with a simple HTTP handler. We would map urls of static files in our rewriter to this handler that would read the static file and serve it, just as IIS would do. Implementation This is how I coded the class. Note that this may not be bullet proof. I only tested it once and I am sure that the logic behind IIS is more complicated that this. If you find errors or think of possible improvements, let me know. Imports System.Web Imports System.Web.Services ' Author: Nicolas Brassard ' For: Solutions Nitriques inc. http://www.nitriques.com ' Date Created: April 18, 2009 ' Last Modified: April 18, 2009 ' License: CPOL (http://www.codeproject.com/info/cpol10.aspx) ' Files: ISAPIDotNetHandler.ashx ' ISAPIDotNetHandler.ashx.vb ' Class: ISAPIDotNetHandler ' Description: Fake ISAPI handler to serve static files. ' Usefull when you want to serve static file that has a rewrited extention. ' Example: It often map html extention to the asp.net dll in order to use url rewritter with .html. ' If you want to still serve static html file, add a rewritter rule to redirect html files to this handler Public Class ISAPIDotNetHandler Implements System.Web.IHttpHandler Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest ' Since we are doing the job IIS normally does with html files, ' we set the content type to match html. ' You may want to customize this with your own logic, if you want to serve ' txt or xml or any other text file context.Response.ContentType = "text/html" ' We begin a try here. Any error that occurs will result in a 404 Page Not Found error. ' We replicate the behavior of IIS when it doesn't find the correspoding file. Try ' Declare a local variable containing the value of the query string Dim uri As String = context.Request("fileUri") ' If the value in the query string is null, ' throw an error to generate a 404 If String.IsNullOrEmpty(uri) Then Throw New ApplicationException("No fileUri") End If ' If the value in the query string doesn't end with .html, then block the acces ' This is a HUGE security hole since it could permit full read access to .aspx, .config, etc. If Not uri.ToLower.EndsWith(".html") Then ' throw an error to generate a 404 Throw New ApplicationException("Extention not allowed") End If ' Map the file on the server. ' If the file doesn't exists on the server, it will throw an exception and generate a 404. Dim fullPath As String = context.Server.MapPath(uri) ' Read the actual file Dim stream As IO.StreamReader = FileIO.FileSystem.OpenTextFileReader(fullPath) ' Write the file into the response context.Response.Output.Write(stream.ReadToEnd) ' Close and Dipose the stream stream.Close() stream.Dispose() stream = Nothing Catch ex As Exception ' Set the Status Code of the response context.Response.StatusCode = 404 'Page not found ' For testing and bebugging only ! This may cause a security leak ' context.Response.Output.Write(ex.Message) Finally ' In all cases, flush and end the response context.Response.Flush() context.Response.End() End Try End Sub ' Automaticly generated by Visual Studio ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable Get Return False End Get End Property End Class Conclusion As you see, with our static files map to this handler using query string (ex.: /ISAPIDotNetHandler.ashx?fileUri=index.html) you will have the same behavior as if you ask for the uri /index.html. Finally, test this only in IIS with the html extension map to aspnet_isapi.dll. Url rewritting will work in Casini (Internal Web Server shipped with Visual Studio) but it’s not the same as with IIS since EVERY request is handle by .NET. Versions First release

    Read the article

  • Static vs Singleton in C# (Difference between Singleton and Static)

    - by Jalpesh P. Vadgama
    Recently I have came across a question what is the difference between Static and Singleton classes. So I thought it will be a good idea to share blog post about it.Difference between Static and Singleton classes:A singleton classes allowed to create a only single instance or particular class. That instance can be treated as normal object. You can pass that object to a method as parameter or you can call the class method with that Singleton object. While static class can have only static methods and you can not pass static class as parameter.We can implement the interfaces with the Singleton class while we can not implement the interfaces with static classes.We can clone the object of Singleton classes we can not clone the object of static classes.Singleton objects stored on heap while static class stored in stack.more at my personal blog: dotnetjalps.com

    Read the article

  • How can I move a library inside a project's source tree and compiling static binaries?

    - by AbrahamVanHelpsing
    How can I move a library inside a project's source tree and compiling static binaries? I want to use a particular tool that utilizes ANCIENT binaries without upgrading it's API usage. This way I can use the old libraries inside the single binary without wrecking the local host environment. I am on nix with netbeans/eclipse/code::blocks. I don't have a problem reading, just looking for a starting point. Any thoughts?

    Read the article

  • Static objects and concurrency in a web application

    - by Ionut
    I'm developing small Java Web Applications on Tomcat server and I'm using MySQL as my database. Up until now I was using a connection singleton for accessing the database but I found out that this will ensure just on connection per Application and there will be problems if multiple users want to access the database in the same time. (They all have to make us of that single Connection object). I created a Connection Pool and I hope that this is the correct way of doing things. Furthermore it seems that I developed the bad habit of creating a lot of static object and static methods (mainly because I was under the wrong impression that every static object will be duplicated for every client which accesses my application). Because of this all the Service Classes ( classes used to handle database data) are static and distributed through a ServiceFactory: public class ServiceFactory { private static final String JDBC = "JDBC"; private static String impl; private static AccountService accountService; private static BoardService boardService; public static AccountService getAccountService(){ initConfig(); if (accountService == null){ if (impl.equalsIgnoreCase(JDBC)){ accountService = new JDBCAccountService(); } } return accountService; } public static BoardService getBoardService(){ initConfig(); if (boardService == null){ if (impl.equalsIgnoreCase(JDBC)){ boardService = new JDBCBoardService(); } } return boardService; } private static void initConfig(){ if (StringUtil.isEmpty(impl)){ impl = ConfigUtil.getProperty("service.implementation"); // If the config failed initialize with standard if (StringUtil.isEmpty(impl)){ impl = JDBC; } } } This was the factory class which, as you can see, allows just one Service to exist at any time. Now, is this a bad practice? What happens if let's say 1k users access AccountService simultaneously? I know that all this questions and bad practices come from a bad understanding of the static attribute in a web application and the way the server handles this attributes. Any help on this topic would be more than welcomed. Thank you for your time!

    Read the article

  • What C++ libraries can be used in game development [closed]

    - by RedShft
    I'm currently in the planning stage for my next game, and since I've been away from C++ for a while I have some questions about helpful libraries. I plan on making a 2D game with SDL, constructing my own simple 2D engine. I plan on making this game for the PC. What libraries would you recommend to make this process easier? What about unittests? What about an enforce operator to throw exceptions? int a = 1; enforce(a == 2); //Throws an exception, Specifically, i'm looking for general purpose libraries, that implement that make my life easier (like boost). Also, a helpful library for physics/collision, AI, XML file parsing (specifically working with the Tiled map editor), and any others that you guys have used that are useful in a 2D game.

    Read the article

  • C++ Building Static Library Project with a Folder Structure

    - by Jake
    I'm working on some static libraries using visual studio 2012, and after building I copy .lib and .h files to respective directories to match a desired hierarchy such as: drive:/libraries/libname/includes/libname/framework drive:/libraries/libname/includes/libname/utitlies drive:/libraries/libname/lib/... etc I'm thinking something similar to the boost folder layout. I have been doing this manually so far. My library solution contains projects, and when I update and recompile I simply recopy files where they need to be. Is there a simpler way to do this? Perhaps a way to compile the project with certain rules per project as to where the projects .h and .lib files should go?

    Read the article

  • Don't Use Static? [closed]

    - by Joshiatto
    Possible Duplicate: Is static universally “evil” for unit testing and if so why does resharper recommend it? Heavy use of static methods in a Java EE web application? I submitted an application I wrote to some other architects for code review. One of them almost immediately wrote me back and said "Don't use "static". You can't write automated tests with static classes and methods. "Static" is to be avoided." I checked and fully 1/4 of my classes are marked "static". I use static when I am not going to create an instance of a class because the class is a single global class used throughout the code. He went on to mention something involving mocking, IOC/DI techniques that can't be used with static code. He says it is unfortunate when 3rd party libraries are static because of their un-testability. Is this other architect correct?

    Read the article

  • signal processing libraries

    - by khinester
    Are there any open source libraries/projects which work in a similar way to http://www.tagattitude.fr/en/products/technology? I am trying to understand the process. At first I thought this could work like when you send a fax to a fax machine. It is basically using the mobile phone’s microphone as a captor and its audio channel as a transporter. Are there any libraries for generating the signal and then being able to decode it?

    Read the article

  • android third party libraries

    - by Terrance
    Its hard to believe that there aren't a ton of awesome third party (possibly open source) libraries out on the web for android using java but, I cant say I have found a great many so far but, droid seems like the only notable one I've come across. Any other majorly useful android libraries out there? Sorry in advanced if there is a dupe out there somewhere (seems like there should be) but if there is by all means post it and let me know.

    Read the article

  • Language Niches and Niche Libraries

    - by Roman A. Taycher
    "Everyone Knows" ... ... that c is widely used for low level programs in large part because operating system/device apis are usually in c. ... that Java is widely used for enterprise applications in large part because of enterprise libraries and ide support. ... that ruby is widely used for webapps thanks in large part because of rails and its library ecosytem But lets go into to details what are the specific niches and subniches. Especially with respect to libraries. Where might you embed lua for application scripting versus python. Where would you use Java vs C#. Which languages do different scientists use? Also which languages have libraries for these subniches? Things like bioperl/scipy/Incanter. Please no flamewars about how nice each language or environment is. This is where they used. Also no complaints about marketing/PHBs. (Manually migrated) I asked this question again after it was closed on stackoverflow.com

    Read the article

  • .htaccess to block by file name possible?

    - by Tiffany Walker
    I have a bunch of files that are secure_xxxxxx.php. Is there a way to use .htaccess to block access to all the secure_* php files based on IP? EDIT: I've tried but I get 500 errors <FilesMatch "^secure_.*\.php$"> order deny all deny from all allow from my ip here </FilesMatch> Don't see any errors in apache error logs either httpd -M Loaded Modules: core_module (static) authn_file_module (static) authn_default_module (static) authz_host_module (static) authz_groupfile_module (static) authz_user_module (static) authz_default_module (static) auth_basic_module (static) include_module (static) filter_module (static) log_config_module (static) logio_module (static) env_module (static) expires_module (static) headers_module (static) setenvif_module (static) version_module (static) proxy_module (static) proxy_connect_module (static) proxy_ftp_module (static) proxy_http_module (static) proxy_scgi_module (static) proxy_ajp_module (static) proxy_balancer_module (static) ssl_module (static) mpm_prefork_module (static) http_module (static) mime_module (static) dav_module (static) status_module (static) autoindex_module (static) asis_module (static) info_module (static) suexec_module (static) cgi_module (static) dav_fs_module (static) negotiation_module (static) dir_module (static) actions_module (static) userdir_module (static) alias_module (static) rewrite_module (static) so_module (static) fastinclude_module (shared) auth_passthrough_module (shared) bwlimited_module (shared) frontpage_module (shared) suphp_module (shared) Syntax OK

    Read the article

  • Understanding the static keyword

    - by user985482
    I have some experience in developing with Java, Javascript and PHP. I am reading Microsoft Visual C# 2010 Step by Step which I feel it is a very good book on introducing you to the C# language. I seem to be having problems in understanding the static keyword. From what I understand this far if a class is declared static all methods and variable have to be static. The main method always is a static method so in the class that the main method exists all variables and methods are declared static if you have to call them in the main method. Also I have noticed that in order to call a static method from another class you do not need to create an object of that you can use the class name. What are the advantages of declaring static variables and methods? When should I declare static variable and methods?

    Read the article

  • Ogre Specific libraries

    - by Molmasepic
    i have a simple question. For people that know and built ogre3D from source as a Static library, What is the order of which the libraries should be linked? The libraries I need to be organized are: Ogre Plugins 'libOgreMain.a' Ogre RenderSystems Boost(version 1.47)link Ogre's Dependencies The reason im asking is because in the Ogre forums, I have asked about this and didnt get a good reply...yet. The other reason is because even though i link to the boost library, i get this error: undefined reference to '_imp___ZN5boost6thread20hardware_concurrencyEv' My compiler is MinGW with CodeBlocks as the IDE And my Main Computer Im building on is Windows Vista 32 bit

    Read the article

  • Why is using C++ libraries so complicated?

    - by Pius
    First of all, I want to note I love C++ and I'm one of those people who thinks it is easier to code in C++ than Java. Except for one tiny thing: libraries. In Java you can simply add some jar to the build path and you're done. In C++ you usually have to set multiple paths for the header files and the library itself. In some cases, you even have to use special build flags. I have mainly used Visual Studio, Code Blocks and no IDE at all. All 3 options do not differ much when talking about using external libraries. I wonder why was there made no simpler alternative for this? Like having a special .zip file that has everything you need in one place so the IDE can do all the work for you setting up the build flags. Is there any technical barrier for this?

    Read the article

  • .NET Libraries Cost More Than Windows?

    - by Kevin Mark
    When looking into libraries to make my programming life a little bit easier I've (almost) always been disappointed by the prices offered. For instance, Actipro's WPF Studio is $650. I suppose that's worth it if you plan to make money from the use of those controls. But take a look at, say, Windows. Windows 7 Ultimate is just about $220. I consider Windows to be a far more complex and "worth-it" product/purchase than a library that runs on it. Why the significant difference in pricing? Do libraries really need to be so expensive, or do they need to charge more in order to make a decent some of money?

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >