Search Results

Search found 32397 results on 1296 pages for 'reference program'.

Page 11/1296 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • Javascript Reference Outer Object From Inner Object

    - by Akidi
    Okay, I see a few references given for Java, but not javascript ( which hopefully you know is completely different ). So here's the code specific : function Sandbox() { var args = Array.prototype.slice.call(arguments) , callback = args.pop() , modules = (args[0] && typeof args[0] === 'string' ? args : args[0]) , i; if (!(this instanceof Sandbox)) { return new Sandbox(modules, callback); } if (!modules || modules[0] === '*') { modules = []; for (i in Sandbox.modules) { if (Sandbox.modules.hasOwnProperty(i)) { modules.push(i); } } } for (i = 0; i < modules.length; i++) { Sandbox.modules[modules[i]](this); } this.core = { 'exp': { 'classParser': function (name) { return (new RegExp("(^| )" + name + "( |$)")); }, 'getParser': /^(#|\.)?([\w\-]+)$/ }, 'typeOf': typeOf, 'hasOwnProperty': function (obj, prop) { return obj.hasOwnProperty(prop); }, 'forEach': function (arr, fn, scope) { scope = scope || config.win; for (var i = 0, j = arr.length; i < j; i++) { fn.call(scope, arr[i], i, arr); } } }; this.config = { 'win' : win, 'doc' : doc }; callback(this); } How do I access this.config.win from within this.core.forEach? Or is this not possible?

    Read the article

  • Remove PostSharp reference after build?

    - by Simon
    Is is possible to get postsharp to remove references to the postsharp assemblies during a build? I have an exe i needs to have a very small footprint. I want to use some of the compile time weaving of postsharp but dont want to have to deploy PostSharp.dll with the exe.

    Read the article

  • Boost binding a function taking a reference

    - by Jamie Cook
    Hi all, I am having problems compiling the following snippet int temp; vector<int> origins; vector<string> originTokens = OTUtils::tokenize(buffer, ","); // buffer is a char[] array // original loop BOOST_FOREACH(string s, originTokens) { from_string(temp, s); origins.push_back(temp); } // I'd like to use this to replace the above loop std::transform(originTokens.begin(), originTokens.end(), origins.begin(), boost::bind<int>(&FromString<int>, boost::ref(temp), _1)); where the function in question is // the third parameter should be one of std::hex, std::dec or std::oct template <class T> bool FromString(T& t, const std::string& s, std::ios_base& (*f)(std::ios_base&) = std::dec) { std::istringstream iss(s); return !(iss >> f >> t).fail(); } the error I get is 1>Compiling with Intel(R) C++ 11.0.074 [IA-32]... (Intel C++ Environment) 1>C:\projects\svn\bdk\Source\deps\boost_1_42_0\boost/bind/bind.hpp(303): internal error: assertion failed: copy_default_arg_expr: rout NULL, no error (shared/edgcpfe/il.c, line 13919) 1> 1> return unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]); 1> ^ 1> 1>icl: error #10298: problem during post processing of parallel object compilation Google is being unusually unhelpful so I hope that some one here can provide some insights.

    Read the article

  • Compare output of program to correct program using bash script, without using text files

    - by Doug
    I've been trying to compare the output of a program to known correct output by using a bash script without piping the output of the program to a file and then using diff on the output file and a correct output file. I've tried setting the variables to the output and correct output and I believe it's been successful but I can't get the string comparison to work correctly. I may be wrong about the variable setting so it could be that. What I've been writing: TEST=`./convert testdata.txt < somesampledata.txt` CORRECT="some correct output" if [ "$TEST"!="$CORRECT" ]; then echo "failed" fi

    Read the article

  • c program pointer

    - by sandy101
    Hello , I am trying some programs in c face a problem with this program #include<stdio.h> int main() { int a=9,*x; float b=3.6,*y; char c='a',*z; printf("the value is %d\n",a); printf("the value is %f\n",b); printf("the value is %c\n",c); x=&a; y=&b; z=&c; printf("%u\n",a); printf("%u\n",b); printf("%u\n",c); x++; y++; z++; printf("%u\n",a); printf("%u\n",b); printf("%u\n",c); return 0; } can any one tell me what is the problem with this and i also want to know that when in the above case if the pointer value is incremented then will it over write the previous value address as suppose that the value we got in the above program (without the increment in the pointer value )is 65524 65520 65519 and after the increment the value of the pointer is 65526(as 2 increment for the int ) 65524(as 4 increment for the float ) 65520(as 1 increment for the char variable ) then if in that case will the new pointer address overwrite the content of the previous address and what value be contained at the new address ......plz help

    Read the article

  • How to reduce redundant code when adding new c++0x rvalue reference operator overloads

    - by Inverse
    I am adding new operator overloads to take advantage of c++0x rvalue references, and I feel like I'm producing a lot of redundant code. I have a class, tree, that holds a tree of algebraic operations on double values. Here is an example use case: tree x = 1.23; tree y = 8.19; tree z = (x + y)/67.31 - 3.15*y; ... std::cout << z; // prints "(1.23 + 8.19)/67.31 - 3.15*8.19" For each binary operation (like plus), each side can be either an lvalue tree, rvalue tree, or double. This results in 8 overloads for each binary operation: // core rvalue overloads for plus: tree operator +(const tree& a, const tree& b); tree operator +(const tree& a, tree&& b); tree operator +(tree&& a, const tree& b); tree operator +(tree&& a, tree&& b); // cast and forward cases: tree operator +(const tree& a, double b) { return a + tree(b); } tree operator +(double a, const tree& b) { return tree(a) + b; } tree operator +(tree&& a, double b) { return std::move(a) + tree(b); } tree operator +(double a, tree&& b) { return tree(a) + std::move(b); } // 8 more overloads for minus // 8 more overloads for multiply // 8 more overloads for divide // etc which also has to be repeated in a way for each binary operation (minus, multiply, divide, etc). As you can see, there are really only 4 functions I actually need to write; the other 4 can cast and forward to the core cases. Do you have any suggestions for reducing the size of this code? PS: The class is actually more complex than just a tree of doubles. Reducing copies does dramatically improve performance of my project. So, the rvalue overloads are worthwhile for me, even with the extra code. I have a suspicion that there might be a way to template away the "cast and forward" cases above, but I can't seem to think of anything.

    Read the article

  • Reference Object calling function in Javascript

    - by Louis
    I have a makeshift events system in JS and the attacher looks like this: events.attach(events.NEW_TASK,this.update); Where this.update is a callback/handler/function. The problem is, when the dispatcher tries to call this handler, it loses it's original context. How can I bind the handler with the context of the object that calls the attach function without passing this as an argument and using that?

    Read the article

  • Modifying reference member from const member function in C++

    - by Philipp
    I am working on const-correctness of my code and just wondered why this code compiles: class X { int x; int& y; public: X(int& _y):y(_y) { } void f(int& newY) const { //x = 3; would not work, that's fine y = newY; //does compile. Why? } }; int main(int argc, char **argv) { int i1=0, i2=0; X myX(i1); myX.f(i2); ... } As far as I understand, f() is changing the object myX, although it says to be const. How can I ensure my compiler complains when I do assign to y? (Visual C++ 2008) Thank a lot!

    Read the article

  • Boost singleton and undefined reference

    - by Ockonal
    Hello, I globally use singleton pattern in my project. To make it easier - boost::singleton. Current project uses Ogre3d library for rendering. Here is some class: class GraphicSystem : public singleton<GraphicSystem> { private: Ogre::RenderWindow *mWindow; public: Ogre::RenderWindow *getWindow() const { return mWindow; } }; In GraphicSystem constructor I fill the mWindow value: mWindow = mRoot->createRenderWindow(...); I cheked it, everything makes normally. So, now I have to use handler for the window in input system (to get window handle). Somewhere else in another class: Ogre::RenderWindow *temp = GraphicSystem::get_mutable_instance().getWindow(); GraphicSystem::get_mutable_instance().getWindow()->getCustomAttribute("WINDOW", &mWindowHandle); temp is 0x00, and there is segfault at last line (getting custon attribute). I can't understand, why does singleton returns undefined pointer for the window. All another singleton-based classes work well.

    Read the article

  • JNA Passing Structure By Reference Help

    - by tyeh26
    Hi all, I'm trying to use JNA to talk over a USB device plugged into the computer. Using Java and a .dll that was provided to me. I am having trouble with the Write function: C code: typedef struct { unsigned int id; unsigned int timestamp; unsigned char flags; unsigned char len; unsigned char data[16]; } CANMsg; CAN_STATUS canplus_Write( CANHANDLE handle, //long CANMsg *msg ); Java Equivalent: public class CANMsg extends Structure{ public int id = 0; public int timestamp = 0; public byte flags = 0; public byte len = 8; public byte data[] = new byte[16]; } int canplus_Write(NativeLong handle, CANMsg msg); I have confirmed that I can open and close the device. The close requires the NativeLong handle, so i am assuming that the CANMsg msg is the issue here. I have also confirmed that the device works when tested with C only code. I have read the the JNA documentation thoroughly... I think. Any pointers. Thanks all.

    Read the article

  • C++ get method - returning by value or by reference

    - by HardCoder1986
    Hello! I've go a very simple question, but unfortunately I can't figure the answer myself. Suppose I've got some data structure that holds settings and acts like a settings map. I have a GetValue(const std::string& name) method, that returns the corresponding value. Now I'm trying to figure out - what kind of return-value approach would be better. The obvious one means making my method act like std::string GetValue(const std::string& name) and return a copy of the object and rely on RVO in performance meanings. The other one would mean making two methods std::string& GetValue(...) const std::string& GetValue(...) const which generally means duplicating code or using some evil constant casts to use one of these routines twice. #Q What would be your choice in this kind of situation and why?

    Read the article

  • What should happen when a reference is deleted?

    - by Apeksha
    I have a vb.net 3.5 application which references a dll (abc.dll, also in .net 3.5) This dll is accessed by the application from time to time. If at anytime during execution, if I delete the dll, I expect the application to throw an error the next time it tries to use a class from the dll. But, this is not the behaviour I see. If I delete the dll before startup, the application throws an error at startup. But not when the dll is deleted after startup. Is this the standard behaviour, or am I doing something wrong? Can I get the app to throw an error if the dll is not found when it tries to use its classes? Thanks in advance.

    Read the article

  • How to pass function reference into arguments

    - by Ockonal
    Hi, I'm using boost::function for making function-references: typedef boost::function<void (SomeClass &handle)> Ref; someFunc(Ref &pointer) {/*...*/} void Foo(SomeClass &handle) {/*...*/} What is the best way to pass Foo into the someFunc? I tried something like: someFunc(Ref(Foo));

    Read the article

  • Real world examples of Ecmascript functions returning a Reference?

    - by Bergi
    Read the EcmaScript specification, section 8.7 The Reference Specification Type: The Reference type is used to explain the behaviour of such operators as delete, typeof, and the assignment operators. […] A Reference is a resolved name binding. Function calls are permitted to return references. This possibility is admitted purely for the sake of host objects. No built-in ECMAScript function defined by this specification returns a reference and there is no provision for a user-defined function to return a reference. Those last two sentences impressed me. With this, you could do things like coolHostFn() = value (valid syntax, btw). So my question is: Are there any EcmaScript implementations that define host function objects which result in Reference values?

    Read the article

  • C++ reference variables

    - by avd
    I have these two functions (with Point2D & LineVector (has 2 Point2D member variables) classes and SQUARE macro predefined) inline float distance(const Point2D &p1,const Point2D &p2) { return sqrt(SQUARE(p2.getX()-p1.getX())+SQUARE(p2.getY()-p1.getY())); } inline float maxDistance(const LineVector &lv1,const LineVector &lv2) { return max(distance(lv1.p1,lv2.p2),distance(lv1.p2,lv2.p1)); } but it gives compilation error in maxDistance() function (line 238) saying: /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_iterator_base_types.h: In instantiation of `std::iterator_traits<Point2D>': quadrilateral.cpp:238: instantiated from here /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_iterator_base_types.h:129: error: no type named `iterator_category' in `class Point2D' /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_iterator_base_types.h:130: error: no type named `value_type' in `class Point2D ' /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_iterator_base_types.h:131: error: no type named `difference_type' in `class Point2D' /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_iterator_base_types.h:132: error: no type named `pointer' in `class Point2D' /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_iterator_base_types.h:133: error: no type named `reference' in `class Point2D' Please suggest what is the error?

    Read the article

  • A program where user enters a string and the program counts the instances of the letters

    - by user1865183
    This is the first C++ program I have ever written and I'm having trouble understanding the order in which operands must be put in. This is for a class, but it looks like I'm not supposed to use the homework tag. Sorry if I'm doing this wrong. This is my input // Get DNA string string st; cout << "Enter the DNA sequence to be analysed: "; cin >> st; This seems to work ok, but I thought I would include it incase this is what I'm doing wrong. This is what I have so far to check that the input is exclusively C,T,A, or G. It runs through the program and simply prints "Please enter a valid sequnce1, please enter a valid sequence2, ... ect. I'm sure I'm doing something very stupid, I just can't figure it out. // Check that the sequence is all C, T, A, G while (i <= st.size()){ if (st[i] != 'c' && st[i] != 'C' && st[i] != 'g' && st[i] != 'G' && st[i] != 't' && st[i] != 'T' && st[i] != 'a' && st[i] != 'A'); cout << "Please enter a valid sequence" << i++; else if (st[i] == c,C,G,t,T,a,A) i++; The second half of my program is to count the number of Cs and Gs in the sequence for (i < st.size() ; i++ ;); for (loop <= st.size() ; loop++;) if (st[loop] == 'c') { count_c++; } else if (st[loop] == C) { count_c++; } else if (st[loop] == g) { count_g++; } else if (st[loop] == G); { count_g++; } cout << "Number of instances of C = " << count_c; cout << "Number of instances of G = " << count_g; It seems like it's not looping, it will count 1 of one of the letters. How do I make it loop? I can't seem to put in endl; anywhere without getting an error back, although I know I'll need it somewhere. Any help or tips to point me in the right direction would be greatly appreciated - I've been working on this code for two days (this is embarrassing to admit).

    Read the article

  • Reference variable to an object instantiated/initialized in another class in Java

    - by Alex
    The reason I'm asking is because I'm getting NullPointerException. I now this is very easy but I'm pretty new programming and find this a bit confusing. So say I have initialized an object in a class and want to access that same object from another class. Like now for instance I'm working on a small Chess game, in my model Game class I have an instance of Board, an object. Board, in turn, has an array of Squares. Square[][]. Game has board, board has Square[][]. Now if I want to access the Square[][] through the object board (in Game) of type Board. Do I just declare a variable with the same name and type or do I have to initialize it again? Board board OR Board board = new Board(); Note, I have already initialized board in the class Game so if I do it again, won't they be two totally different Board objects?

    Read the article

  • a design to avoid circular reference in this scenario

    - by BDotA
    Here is our dependency tree: BigApp - Child Apps - Libraries ALL of our components are HEAVILY using one of the Libraries as above ( LibA). But it has a ‘few’ public methods that require classes from ‘higher-level’ assemblies and we want to avoid CIRCULAR references. What do you propose as a good design for this?

    Read the article

  • How to make a copy of a char and not a reference in C++

    - by Phenom
    If I declare a function like this: string hash (char* key) then any change I make to key will also change it's value when the function exits, correct? I want to make a copy of it in the function so that I can safely change it without changing the original value. I tried this, but it doesn't work. string temp = key; How can it be done?

    Read the article

  • pass variable by reference within class? in php

    - by user151841
    I'm working on a hex color class where you can change the color values of any hex code color. In my example, I haven't finished the hex math, but it's not completely relevant to what I'm explaining here. Naively, I wanted to start to do something that I don't think can be done. I wanted to pass object properties in a method call. Is this possible? class rgb { private $r; private $b; private $g; public function __construct( $hexRgb ) { $this->r = substr($hexRgb, 0, 2 ); $this->g = substr($hexRgb, 2, 2 ); $this->b = substr($hexRgb, 4, 2 ); } private function add( & $color, $amount ) { $color += amount; // $color should be a class property, $this->r, etc. } public function addRed( $amount ) { self::add( $this->r, $amount ); } public function addGreen( $amount ) { self::add( $this->g, $amount ); } public function addBlue( $amount ) { self::add( $this->b, $amount ); } } If this is not possible in PHP, what is this called and in what languages is it possible? I know I could do something like public function add( $var, $amount ) { if ( $var == "r" ) { $this->r += $amount } else if ( $var == "g" ) { $this->g += $amount } ... } But I want to do it this cool way.

    Read the article

  • C++ Type error with Object versus Object reference

    - by muddybruin
    I have the following function (which worked in Visual Studio): bool Plane::contains(Vector& point){ return normalVector.dotProduct(point - position) < -doubleResolution; } When I compile it using g++ version 4.1.2 , I get the following error: Plane.cpp: In member function âvirtual bool Plane::contains(Vector&)â: Plane.cpp:36: error: no matching function for call to âVector::dotProduct(Vector)â Vector.h:19: note: candidates are: double Vector::dotProduct(Vector&) So as you can see, the compiler thinks (point-position) is a Vector but it's expecting Vector&. What's the best way to fix this? I verified that this works: Vector temp = point-position; return normalVector.dotProduct(temp) < -doubleResolution; But I was hoping for something a little bit cleaner. I heard a suggestion that adding a copy constructor might help. So I added a copy constructor to Vector (see below), but it didn't help. Vector.h: Vector(const Vector& other); Vector.cpp: Vector::Vector(const Vector& other) :x(other.x), y(other.y), z(other.z), homogenous(other.homogenous) { }

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >