Search Results

Search found 3592 results on 144 pages for 'pointer'.

Page 75/144 | < Previous Page | 71 72 73 74 75 76 77 78 79 80 81 82  | Next Page >

  • How to interpret binary data as an integer?

    - by StackedCrooked
    The codebase at work contains some code that looks roughly like this: #define DATA_LENGTH 64 u_int32 SmartKey::SerialNumber() { unsigned char data[DATA_LENGTH]; // ... initialized data buffer return *(u_int32*)data; } This code works correctly, but GCC gives the following warning: warning: dereferencing pointer ‘serialNumber’ does break strict-aliasing rules Can someone explain this warning? Is this code potentially dangerous? How can it be improved?

    Read the article

  • Object allocation in C++

    - by Poiuyt
    char *myfunc() { char *temp = "string"; return temp; } In this piece of code, where does the allocation of the object pointed to by temp happen and what would be its scope? Is this function a valid way to return a char* pointer?

    Read the article

  • Can I Have Polymorphic Containers With Value Semantics in C++11?

    - by John Dibling
    This is a sequel to a related post which asked the eternal question: Can I have polymorphic containers with value semantics in C++? The question was asked slightly incorrectly. It should have been more like: Can I have STL containers of a base type stored by-value in which the elements exhibit polymorphic behavior? If you are asking the question in terms of C++, the answer is "no." At some point, you will slice objects stored by-value. Now I ask the question again, but strictly in terms of C++11. With the changes to the language and the standard libraries, is it now possible to store polymorphic objects by value in an STL container? I'm well aware of the possibility of storing a smart pointer to the base class in the container -- this is not what I'm looking for, as I'm trying to construct objects on the stack without using new. Consider if you will (from the linked post) as basic C++ example: #include <iostream> using namespace std; class Parent { public: Parent() : parent_mem(1) {} virtual void write() { cout << "Parent: " << parent_mem << endl; } int parent_mem; }; class Child : public Parent { public: Child() : child_mem(2) { parent_mem = 2; } void write() { cout << "Child: " << parent_mem << ", " << child_mem << endl; } int child_mem; }; int main(int, char**) { // I can have a polymorphic container with pointer semantics vector<Parent*> pointerVec; pointerVec.push_back(new Parent()); pointerVec.push_back(new Child()); pointerVec[0]->write(); pointerVec[1]->write(); // Output: // // Parent: 1 // Child: 2, 2 // But I can't do it with value semantics vector<Parent> valueVec; valueVec.push_back(Parent()); valueVec.push_back(Child()); // gets turned into a Parent object :( valueVec[0].write(); valueVec[1].write(); // Output: // // Parent: 1 // Parent: 2 }

    Read the article

  • Making a char function parameter const?

    - by Helper Method
    Consider this function declaration: int IndexOf(const char *, char); where char * is a string and char the character to find within the string (returns -1 if the char is not found, otherwise its position). Does it make sense to make the char also const? I always try to use const on pointer parameters but when something is called by value, I normally leave the const away. What are your thoughts?

    Read the article

  • object reference set in java

    - by landon9720
    I need to create a Set of objects. The concern is I do not want to base the hashing or the equality on the objects' hashCode and equals implementation. Instead, I want the hash code and equality to be based only on each object's reference identity (i.e.: the value of the reference pointer). I'm not sure how to do this in Java. The reasoning behind this is my objects do not reliably implement equals or hashCode, and in this case reference identity is good enough.

    Read the article

  • Using two threads and controlling one from the other in java?

    - by sidra
    Can someone please help me out. I need to use two threads in a way that one thread will run permanently while(true) and will keep track of a positioning pointer (some random value coming in form a method). This thread has a logic, if the value equals something, it should start the new thread. And if the value does not equal it should stop the other thread. Can someone give me some code snippet (block level) about how to realize this?

    Read the article

  • How to force a gtk tooltip to be shown?

    - by markuz
    I have an application and I want to show a tooltip every time a user set the focus on a entry widget. Do you know a way to force a gtk Tooltip to be shown?, because right now it only shows when the user puts the mouse pointer over the entry, but the application in production will have no mouse at all.

    Read the article

  • Styling related issue in IE8

    - by Ajith
    I am using a background image to display as a button. The button shows up well in all versions of firefox, chrome, opera etc. However, the image fails to render itself in IE8. Only the image is not being shown, some of the other class styling gets applied such as width, height etc. Even more confounding is that in another page(though a different class and style sheet), an image of similar proportions gets displayed in similar usage. The image format is JPG. I'm copy-pasting the valid style attributes for both cases as shown by firebug below. None of the below buttons are displayed. button classes are applied as class="cart-button login", class="cart-button update", class="cart-button checkout" and class="cart-button continue" and are inside some divs. .cart-button{ height: 28px; cursor: pointer; border: none; float: left; } .cart-button:hover{ background-position: 0 -28px; } .login{ width: 58px; background:url(/../../templates/animalcare/i/login.jpg)no-repeat; margin:0 0 20px 0; clear: both; } .update{ width: 63px; background:url(/../../templates/animalcare/i/update.jpg)no-repeat; margin:0 0 20px 15px; float: left; } .checkout{ width: 77px; background:url(/../../templates/animalcare/i/checkout.jpg)no-repeat; float:right; margin:0 25px 30px 10px; } .continue{ width: 132px; background:url(/../../templates/animalcare/i/continue.jpg)no-repeat; float:right; margin:0 0 30px 0px; } The below is the only image button that gets displayed. It is located inside a table. It is in a different style sheet - hence the path difference. .add-to-cart{ width:102px; height:28px; float:left; background:url(i/add_to_cart.jpg) no-repeat; cursor:pointer; border:none; margin:10px 0 5px 0; } .add-to-cart:hover{ background-position:0 -28px; }

    Read the article

  • c++ memcpy return value

    - by knittl
    according to http://www.cplusplus.com/reference/clibrary/cstring/memcpy/ c++'s memcpy takes three parameters: destination, source and size/bytes. it also returns a pointer. why is that so? aren't the parameters enough to input and copy data. or am i misunderstanding something? the examples don't use the return value

    Read the article

  • How to calculate the cycles that change one permutation into another?

    - by fortran
    Hi, I'm looking for an algorithm that given two permutations of a sequence (e.g. [2, 3, 1, 4] and [4, 1, 3, 2]) calculates the cycles that are needed to convert the first into the second (for the example, [[0, 3], [1, 2]]). The link from mathworld says that Mathematica's ToCycle function does that, but sadly I don't have any Mathematica license at hand... I'd gladly receive any pointer to an implementation of the algorithm in any FOSS language or mathematics package. Thanks!

    Read the article

  • How to compare two vectors, in C++

    - by Vincenzo
    This is my code: #include <algorithm> void f() { int[] a = {1, 2, 3, 4}; int[] b = {1, 2, 100, 101}; // I want to do something like this: // int* found = compare(a[0], a[3], b[0]); // in order to get a pointer to a[2] } Maybe I missed this algorithm in the manual… Please help :)

    Read the article

  • c++ : looking away to implemnt this senario

    - by user63898
    Hi im looking to find how to implement this scenario: i have logic code that is inside function, now i like to be able to execute this function in a separate thread. now what i have is a raw implementation of this .. i simple Init the Thread that in its Start/Run method i keep the function logic . how can i make it more generic ? so i could send the function ( mybe function pointer ) to generic thread factory/pool ? in c++

    Read the article

  • Access element of pointed std::vector

    - by user146780
    I have a function where I provide a pointer to a std::vector. I want to make x = to vector[element] but i'm getting compiler errors. I'm doing: void Function(std::vector<int> *input) { int a; a = *input[0]; } What is the right way to do this? Thanks

    Read the article

  • Remove button box

    - by stdio
    I'm writing an application in C and I've a GtkLinkButton that contains a GtkStockItem. How can I remove the button box that appears when mouse pointer is on and when I click it?

    Read the article

  • Problem with C++ classes

    - by Mike
    I have a class defined called extBlock. I then make an instance of that class with this extBlock mainBlock = new extBlock(1, 1024); I get this error: error C2440: 'initializing' : cannot convert from 'extBlock *' to 'extBlock' Can anyone help me with why I am getting this error. I have seen examples online of declaring it like this with a pointer extBlock *mainBlock = new extBlock(1, 1024); But if I do it this way it does not let me call the functions of mainBlock

    Read the article

  • Is it worth setting pointers to NULL in a destructor?

    - by Rob
    Imagine I have a class that allocates memory (forget about smart pointers for now): class Foo { public: Foo() : bar(new Bar) { } ~Foo() { delete bar; } void doSomething() { bar->doSomething(); } private: Bar* bar; }; As well as deleting the objects in the destructor is it also worth setting them to NULL? I'm assuming that setting the pointer to NULL in the destructor of the example above is a waste of time.

    Read the article

  • Create folder for todays date

    - by Ram
    Hi, I have a folder named as 2010. In this I want a folder for each month like "Jan10", "Feb10"....."Dec10" In each month folder I want to create folder for "Todays date" I have create a shortcut for that 2010 folder with Target as C:\WINDOWS\explorer.exe /n, /e, /select, F:\2010 I want a functionality that will execute when I click the shortcut for f:\2010 icon. Any pointer would be great help.

    Read the article

  • Interpreter more strict

    - by pacopepe
    Hi, Today, i lost a lot of time fixing a stupid error in my code. Very simplified, the problem was this: def f(): return 2 2 == f I forgot to write the parenthesis in the sentence, so I compared a pointer function with a number. Ok, my question: Is there any way to change the interpreter to be more stricted with the code? Show more warnings for example... Thanks ^^

    Read the article

  • Any pitfalls using char* instead of void* when writing cross platform code?

    - by UberMongoose
    Is there any pitfalls when using char*'s to write cross platform code that does memory access? I'm working on a play memory allocator to better understand how to debug memmory issues. I have come to believe char*'s are preferable because of the ability to do pointer arithmetic and derefernce them over void*'s, is that true? Do the following assumptions always hold true on different common platforms? sizeof(char) == 1 sizeof(char*) == sizeof(void*) sizeof(char*) == sizeof(size_t)

    Read the article

< Previous Page | 71 72 73 74 75 76 77 78 79 80 81 82  | Next Page >