Search Results

Search found 37004 results on 1481 pages for 'public static'.

Page 18/1481 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • Accessing "Public" methods from "Private" methods in javascript class

    - by mon4goos
    Is there a way to call "public" javascript functions from "private" ones within a class? Check out the class below: function Class() { this.publicMethod = function() { alert("hello"); } privateMethod = function() { publicMethod(); } this.test = function() { privateMethod(); } } Here is the code I run: var class = new Class(); class.test(); Firebug gives this error: publicMethod is not defined: [Break on this error] publicMethod(); Is there some other way to call publicMethod() within privateMethod() without accessing the global class variable [i.e. class.publicMethod()]?

    Read the article

  • Static compilation in the .NET world

    - by AngryHacker
    I'll be writing a small desktop app for a client that has WinXP machines and they won't be installing the .NET framework (at least not for me). So my choices are limited to either C++ or VB6, neither of which sound great. I remember reading back in the day that Mono came up with a static compiler, but recently the only thing I could find is Miguel de Icaza's entry on static compilation for a game engine for the purposes of running the app on the iPhone - not what I had in mind. Are there any products out there, free or commercial that will allow me to statically compile my .net 3.5 winform app? Thanks

    Read the article

  • Static Function Help C++

    - by Alex
    I can't get past this issue I am having. Here's a simple example: class x { public: void function(void); private: static void function2(void); void x::function(void) { x::function2(void); } static void function2(void) { //something } } I get errors in which complain about function2 being private. If I make it public (which I don't really want to do) I get errors about an undefined reference to function2. What am I doing wrong? Thank you!

    Read the article

  • A function's static and dynamic parent

    - by legends2k
    I'm reading Thinking in C++ (vol. 2): Whenever a function is called, information about that function is pushed onto the runtime stack in an activation record instance (ARI), also called a stack frame. A typical stack frame contains (1) the address of the calling function (so execution can return to it), (2) a pointer to the ARI of the function’s static parent (the scope that lexically contains the called function, so variables global to the function can be accessed), and (3) a pointer to the function that called it (its dynamic parent). The path that logically results from repetitively following the dynamic parent links is the dynamic chain, or call chain I'm unable to comprehend what the author means as function's static and dynamic parent. Also am not able to differentiate between item 1, 2 or 3. They all seem to be the same. Can someone please explain this passage to me?

    Read the article

  • Static Member Variables of the Same Class in C++

    - by helixed
    I'm trying to create a class which contains a static pointer to an instance of itself. Here's an example: A.h: #include <iostream> #ifndef _A_H #define _A_H class A { static A * a; }; A * a = NULL; #endif However, when I include A.h in another file, such as: #include "A.h" class B { }; I get the following error: ld: duplicate symbol _a in /Users/helixed/Desktop/Example/build/Example.build/Debug/Example.build/Objects-normal/x86_64/B.o and /Users/helixed/Desktop/Example/build/Example.build/Debug/Examplebuild/Objects-normal/x86_64/A.o I'm using the Xcode default compiler on Mac OS X Snow Leopard. Thanks, helixed

    Read the article

  • Static string variable in Objective C on iphone

    - by Prajakta
    Hi, How to create & access static string in iPhone (objective c)? I declare static NSString *str = @"OldValue" in class A. If i assign some value to this in class B as str = @"NewValue". This value persists for all methods in class B. But if I access it in class C (after assignment in B) I am getting it as OldValue. Am I missing something? Should i use extern in other classes? Thanks & Regards, Yogini

    Read the article

  • Looking for a better way to integrate a static list into a set of classes

    - by EvilTeach
    I'm trying to expand my sons interest from Warcraft 3 programming into C++ to broaden his horizons to a degree. We are planning on porting a little game that he wrote. The context goes something like this. There are Ships and Missiles, for which Ships will use Missiles and interact with them A Container exists which will hold 'a list' of ships. A Container exists which will hold 'a list' of planets. One can apply a function over all elements in the Container (for_each) Ships and Missles can be created/destroyed at any time New objects automatically insert themselves into the proper container. I cobbled a small example together to do that job, so we can talk about topics (list, templates etc) but I am not pleased with the results. #include <iostream> #include <list> using namespace std; /* Base class to hold static list in common with various object groups */ template<class T> class ObjectManager { public : ObjectManager ( void ) { cout << "Construct ObjectManager at " << this << endl; objectList.push_back(this); } virtual ~ObjectManager ( void ) { cout << "Destroy ObjectManager at " << this << endl; } void for_each ( void (*function)(T *) ) { for (objectListIter = objectList.begin(); objectListIter != objectList.end(); ++objectListIter) { (*function)((T *) *objectListIter); } } list<ObjectManager<T> *>::iterator objectListIter; static list<ObjectManager<T> *> objectList; }; /* initializer for static list */ template<class T> list<ObjectManager<T> *> ObjectManager<T>::objectList; /* A simple ship for testing */ class Ship : public ObjectManager<Ship> { public : Ship ( void ) : ObjectManager<Ship>() { cout << "Construct Ship at " << this << endl; } ~Ship ( void ) { cout << "Destroy Ship at " << this << endl; } friend ostream &operator<< ( ostream &out, const Ship &that ) { out << "I am a ship"; return out; } }; /* A simple missile for testing */ class Missile : public ObjectManager<Missile> { public : Missile ( void ) : ObjectManager<Missile>() { cout << "Construct Missile at " << this << endl; } ~Missile ( void ) { cout << "Destroy Missile at " << this << endl; } friend ostream &operator<< ( ostream &out, const Missile &that ) { out << "I am a missile"; return out; } }; /* A function suitable for the for_each function */ template <class T> void show ( T *it ) { cout << "Show: " << *it << " at " << it << endl; } int main ( void ) { /* Create dummy planets for testing */ Missile p1; Missile p2; /* Demonstrate Iterator */ p1.for_each(show); /* Create dummy ships for testing */ Ship s1; Ship s2; Ship s3; /* Demonstrate Iterator */ s1.for_each(show); return 0; } Specifically, The list is effectively embedded in each ship though the inheritance mechanism. One must have a ship, in order to access the list of ships. One must have a missile in order to be able to access the list of missiles. That feels awkward. My question boils down to "Is there a better way to do this?" Automatic object container creation Automatic object insertion Container access without requiring an object in the list to access it. I am looking for better ideas. All helpful entries get an upvote. Thanks Evil.

    Read the article

  • Static Access To Multiple Instance Variable

    - by Qua
    I have a singleton instance that is referenced throughout the project which works like a charm. It saves me the trouble from having to pass around an instance of the object to every little class in the project. However, now I need to manage multiple instances of the previous setup, which means that the singleton pattern breaks since each instance would need it's own singleton instance. What options are there to still maintain static access to the singleton? To be more specific, we have our game engine and several components and plugins reference the engine through a static property. Now our server needs to host multiple game instances each having their own engine, which means that on the server side the singleton pattern breaks. I'm trying to avoid all the classes having the engine in the constructor.

    Read the article

  • What static analysis tools are available for C#?

    - by Paul Mrozowski
    What tools are there available for static analysis against C# code? I know about FxCop and StyleCop. Are there others? I've run across NStatic before but it's been in development for what seems like forever - it's looking pretty slick from what little I've seen of it, so it would be nice if it would ever see the light of day. Along these same lines (this is primarily my interest for static analysis), tools for testing code for multithreading issues (deadlocks, race conditions, etc.) also seem a bit scarce. Typemock Racer just popped up so I'll be looking at that. Anything beyond this? Real-life opinions about tools you've used are appreciated.

    Read the article

  • Referring to this pointer in a static assert?

    - by Tyson Jacobs
    Is it possible to write a static assert referring to the 'this' pointer? I do not have c++11 available, and BOOST_STATIC_ASSERT doesn't work. struct blah { void func() {BOOST_STATIC_ASSERT(sizeof(*this));} }; Produces: error C2355: 'this' : can only be referenced inside non-static member functions error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE' In MSVC 2008. Motivation: #define CLASS_USES_SMALL_POOL() \ void __small_pool_check() {BOOST_STATIC_ASSERT(sizeof(*this) < SMALL_MALLOC_SIZE;} \ void* operator new(size_t) {return SmallMalloc();} \ void operator delete(void* p) {SmallFree(p);}

    Read the article

  • caching static files for ruby on rails application using nginx

    - by splintercell
    I have been trying for some time to serve & cache static files for my rails app using nginx. the rails app server runs mongrel_cluster and is deployed on a different host than that of nginx. following many of the available discussions I tried the following server { listen 80; server_name www.myappserver.com; ssl on; root /var/apps/myapp/current/public; location ~ ^/(images|javascripts|stylesheets)/ { root /var/apps/myapp/current; expires 10y; } location / { proxy_pass http://myapp_upstream; } } But nginx fails to find the images and to load the css and js files. Can anyone help me out here? My aim is to configure nginx in such a way that it caches the static files till expiry. Please suggest me some way to achieve this or am I missing any point here?

    Read the article

  • Static Website - Converting to Dynamic, need to import information from database on different host

    - by gvernold
    This seems really complicated to ask about so I hope someone can help: We have a long time running static website held with a hosting company that provide PHP, Ruby-on-Rails and Drupal/Joomla support. A little limited I know but we got reasonably decent search engine rankings and didn't want them to drop. We have two much more recently created sites on another host written in Python/Django. The original site is now too big to handle statically and we want to create a more dynamic site in its place without changing servers/webhosts. The data we want to provide the 'new' dynamic site is from the same database providing the Django sites. What is the best solution to build the new site with? Is it better to create PHP pages that connect to the database on the other host? Ruby-on-rails seems like a very fast development environment not too dissimilar to Django, would we be able to fetch data from the existing databases into a rails site and use similar urls to our old static pages?

    Read the article

  • Programmatically create static arrays at compile time in C++

    - by Hippicoder
    One can define a static array at compile time as follows: const std::size_t size = 5; unsigned int list[size] = { 1, 2, 3, 4, 5 }; Question 1 - Is it possible by using various kinds of metaprogramming techniques to assign these values "programmatically" at compile time? Question 2 - Assuming all the values in the array are to be the same barr a few, is it possible to selectively assign values at compile time in a programmatic manner? eg: const std::size_t size = 7; unsigned int list[size] = { 0, 0, 2, 3, 0, 0, 0 }; Solutions using C++0x are welcome The array may be quite large, few hundred elements long The array for now will only consist of POD types It can also be assumed the size of the array will be known beforehand, in a static compile-time compliant manner. Solutions must be in C++ (no script or codegen based solutions)

    Read the article

  • BizTalk external assembly namespace and static methods

    - by SteveC
    Is there some restriction in BizTalk 2006 R2 to accessing static methods in external assemblies when the assembly has a "." in the name ? I have the solution set-up with the BizTalk project "FooBar", and the external assembly project "FooBar.Helper" (strongly signed and GAC'ed) with a class "Demo" (public and serializable), which is referenced in the BizTalk project I can create a BizTalk variable of type "FooBar.Helper.Demo" and access an instance method fine, but an expression window the Intellisense shows the FooBar namespace, but if I dot it, I get the error "illegal dotted name" ??? However I can add another project, "ExtComp" with class "Test" and it's static methods are displayed in Intellisense !!! The only difference I can see is the first external assembly has the dot in it

    Read the article

  • C++ - Resources in static library question

    - by HardCoder1986
    Hello! This isn't a duplicate of http://stackoverflow.com/questions/531502/vc-resources-in-a-static-library because it didn't help :) I have a static library with TWO .rc files in it's project. When I build my project using the Debug configuration, I retrieve the following error (MSVS2008): fatal error LNK1241: resource file res_yyy.res already specified Note, that this happens only in Debug and Release library builds without any troubles. The command line for Resources page in project configuration looks the same for every build: /fo"...(Path here)/Debug/project_name.res" /fo"...(Path here)/Release/project_name.res" and I can't understand what's the trouble. Any ideas? UPDATE I don't know why this happens, but when I turn "Use Link-Time Code Generation" option on the problem goes away. Could somebody explain why does this happen? I feel like MS-compiler is doing something really strange here. Thanks.

    Read the article

  • Problems adding static library QT project

    - by Smek
    I have problems adding a static library to my Qt project. I have two project one is my static library and the other one is a Qt GUI project. As I add all classes to my GUI project as c++ or header files everything works just fine but I want this to be in a separate library. When I select the option to add a library I check External library then I select the .a file I have build and the folder where my header files can be found because I am working on a Mac I select Mac as the target platform. Then I click continue and then done. macx: LIBS += -L$$PWD/../../MyLib/build-MyLib-Desktop_Qt_5_2_1_clang_64bit-Debug/ -lMyLib INCLUDEPATH += $$PWD/../../MyLib/build-MyLib-Desktop_Qt_5_2_1_clang_64bit-Debug/include DEPENDPATH += $$PWD/../../MyLib/build-MyLib-Desktop_Qt_5_2_1_clang_64bit-Debug/include macx: PRE_TARGETDEPS += $$PWD/../../MyLib/build-MyLib-Desktop_Qt_5_2_1_clang_64bit-Debug/libMyLib.a When I build my GUI project I get the following error: The process "/usr/bin/make" exited with code 2. Can anyone tell me what the problem can be and how to resolve the problem? Thanks

    Read the article

  • static const double in c++

    - by Crystal
    Is this the proper way to use a static const variable? In my top level class (Shape) #ifndef SHAPE_H #define SHAPE_H class Shape { public: static const double pi; private: double originX; double originY; }; const double Shape::pi = 3.14159265; #endif And then later in a class that extends Shape, I use Shape::pi. I get a linker error. I moved the const double Shape::pi = 3.14... to the Shape.cpp file and my program then compiles. Why does that happen? thanks.

    Read the article

  • undefined reference to static member variable

    - by Max
    Hi. I have this class that has a static member. it is also a base class for several other classes in my program. Here's its header file: #ifndef YARL_OBJECT_HPP #define YARL_OBJECT_HPP namespace yarlObject { class YarlObject { // Member Variables private: static int nextID; // keeps track of the next ID number to be used int ID; // the identifier for a specific object // Member Functions public: YarlObject(): ID(++nextID) {} virtual ~YarlObject() {} int getID() const {return ID;} }; } #endif and here's its implementation file. #include "YarlObject.hpp" namespace yarlObject { int YarlObject::nextID = 0; } I'm using g++, and it returns three undefined reference to 'yarlObject::YarlObject::nextID linker errors. If I change the ++nextID phrase in the constructor to just nextID, then I only get one error, and if I change it to 1, then it links correctly. I imagine it's something simple, but what's going on?

    Read the article

  • Encrypt string with public key only

    - by vlahovic
    i'm currently working on a android project where i need to encrypt a string using 128 bit AES, padding PKCS7 and CBC. I don't want to use any salt for this. I've tried loads of different variations including PBEKey but i can't come up with working code. This is what i currently have: String plainText = "24124124123"; String pwd = "BobsPublicPassword"; byte[] key = pwd.getBytes(); key = cutArray(key, 16); byte[] input = plainText.getBytes(); byte[] output = null; SecretKeySpec keySpec = null; keySpec = new SecretKeySpec(key, "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding"); cipher.init(Cipher.ENCRYPT_MODE, keySpec); output = cipher.doFinal(input); private static byte[] cutArray(byte[] arr, int length){ byte[] resultArr = new byte[length]; for(int i = 0; i < length; i++ ){ resultArr[i] = arr[i]; } return resultArr; } Any help appreciated //Vlahovic

    Read the article

  • Defining private static class member

    - by mnn
    class B { /* ... */ }; class A { public: A() { obj = NULL; } private: static B* obj; }; However this produces huge mass of linker errors that symbol obj is unresolved. What's the "correct" way to have such private static class member without these linker errors? Edit: I tried this: B *A::obj = NULL; but I got about same amount of linker errors however this time about already defining A::obj. (LNK2005). Also I get LNK4006 warnings, also about A::obj

    Read the article

  • Pass form object value to static method

    - by jrubengb
    Hi, I need to take a form object value and pass it into a static method: public void SetCalendarStartSafe(DateTime startDateSafe) { startDateSafe = calendarStart.Value; } private static DataTable GetData() { frmMain frm = new frmMain(); DateTime startDate = new frmMain(); frm.SetCalendarStartSafe(startDate); } However I keep getting today's current date whenever I try this approach, even if the specified calendar date on the form is different. How can I can the user-specified calendar date from the original frmMain object? Thanks in advance for any guidance.

    Read the article

  • Getting count() of class static array

    - by xylar
    Is it possible to get the count of a class defined static array? For example: class Model_Example { const VALUE_1 = 1; const VALUE_2 = 2; const VALUE_3 = 3; public static $value_array = array( self::VALUE_1 => 'boing', self::VALUE_2 => 'boingboing', self::VALUE_3 => 'boingboingboing', ); public function countit() { // count number $total = count(self::$value_array ); echo ': '; die($total); } } At the moment calling the countit() method returns :

    Read the article

  • C++ - defining static const integer members in class definition

    - by HighCommander4
    My understanding is that C++ allows static const members to be defined inside a class so long as it's an integer type. Why, then, does the following code give me a linker error? #include <algorithm> #include <iostream> class test { public: static const int N = 10; }; int main() { std::cout << test::N << "\n"; std::min(9, test::N); } The error I get is: test.cpp:(.text+0x130): undefined reference to `test::N' collect2: ld returned 1 exit status Interestingly, if I comment out the call to std::min, the code compiles and links just fine (even though test::N is also referenced on the previous line). Any idea as to what's going on? My compiler is gcc 4.4 on Linux.

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >