Search Result

Collapse
16 results in 0.0016 seconds.
Keywords
Members
Tags
pointers
  •  

  • pointing a variable to a member function outside a class

    Hello, my question is this.
    In C++, how do i call a method member of class A from a class B, using a pointer.
    By the way Class A and B are of different types.

    I read that when a pointer is pointing to member function it can only point member functions within the class. But how can i point to a member function outside the class.?????



    for example

    class A...
    See more | Go to post

  • format ‘%X’ expects argument of type ‘unsigned int’, but argument 3 has type 'int *'

    I don't understand why the piece of code below returns me the error:

    warning: format ‘%X’ expects argument of type ‘unsigned int’, but argument 3 has type ‘int *’ [-Wformat]

    Code:
        int *v=malloc(10*sizeof(int));
        int i;
        for(i=0;i<10;i++) v[i]=i;
        for(i=0;i<10;i++) printf("v[i]=%+2d &v[i]=%#.10X | 
        *  (v+i)=%+2d (v+i)=%#.10X\n",v[i],&v[i],*(v+i),(v+i));
    See more | Go to post

  • KENNY LIU
    started a topic C++ how to reverse singly linked list
    in C

    C++ how to reverse singly linked list

    My class

    Code:
    
    #ifndef NODE_H
    #define NODE_H
    
    #include <cstdlib> // Provides size_t and NULL
    
    class Node
    {
    public:
    
    // TYPEDEF
    typedef int value_type;
    
    // CONSTRUCTOR
    Node(const value_type& init_data = value_type(), Node* init_link = NULL)
    {
    data_field = init_data; 
    link_field = init_link;
    ...
    See more | Go to post

  • Erjan
    started a topic delete node using only one pointer
    in C

    delete node using only one pointer

    i m trying to solve a textbook problem
    to delete a node using one pointer
    my code looks like this:
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    struct node{
       int first ;
       struct node *next ;
    } ;
    
    struct node *add_to_list(struct node *lst, int n){
       struct node *newnode ;
       newnode = malloc(sizeof(struct node)) ;
       if(newnode == NULL){
    ...
    See more | Go to post

  • Bharathi Kanama
    started a topic Stack Overflow in C
    in C

    Stack Overflow in C

    Hi,

    I am using pointers to generate a network of paths for a simulation run.

    I am getting "stack overflow" error, when the network reaches larger sizes.

    the program currently uses recursion, which is unavoidable in this case.

    Is there a way I trouble shoot this error, either by release of temp data structures called in subroutines or by increasing the stack size for this project....
    See more | Go to post

  • how to implement Java equivalent of Function Pointers via abstract classes

    Im trying to to create a simple 4 function calculator using a jump table without switch case or if/else statements. I understand I can create the jump table via function pointers but I am kindda blanking out. I've started with the addition and subtraction part of the program but am trying to grasp the design/strategy to use. I am also getting an error when putting the method in the array, so far this is what i have:....I'm also trying to figure out...
    See more | Go to post

  • DopeyinIdaho
    started a topic C# unmanaged data structure declaration

    C# unmanaged data structure declaration

    We have a lot of legacy code written in C/C++ that maintains data in shared memory structures. In the C/C++ implementations , for a lot of functions, we get a pointer to the shared memory address then cast that pointer to the type of structure that is contained in that shared memory.

    I have a need to "port" the same interface to C#. The requirements are that we cannot change any of the C/C++ implementation and the interfaces...
    See more | Go to post

  • Return class(a) pointer in another class(b) function

    So i've been working on a program in c++ that uses classes, and i am having a few problems with returning a class value from another class's function.

    So i have a class called X, which is essentially a class that defines a linked list, and has some of the basic operations. In that class i have a '[]' operator that is overloaded with each value in the linked list. The operator can also override values in the linked list using
    ...
    See more | Go to post
    Last edited by Nepomuk; Sep 12 '10, 08:23 AM. Reason: Please use [CODE] tags

  • Address stored by pointers is PHYSICAL or LOGICAL

    Me and 1 of my friend were arguing, over the nature of address stored by pointers in c language.

    He was saying that its logical address, while i thought he is wrong. can anyone plz tell me who is right, he or me, plz give the reasion for the same.

    thanx in advance.
    See more | Go to post

  • EARNEST
    started a topic Struct, char array and pointer problem.
    in C

    Struct, char array and pointer problem.

    Code:
    #include <string.h>
    #include <ncurses.h>
    #include <time.h>
    #include <stdlib.h>
    
    typedef struct builder{
    	int locX;
    	int locY;
    	char charValue_H;
    	char charValue_T;
    	char *charArray_B;
    } sbuilder;
    
    void drawborders();
    void initialize(sbuilder *stopass);
    bool collisiondetection();
    
    int main()
    {
    ...
    See more | Go to post

  • JSchaenzle
    started a topic Passing strings to and from functions
    in C

    Passing strings to and from functions

    I am trying to pass a string to a Mid() function, return a portion of the string, and then convert that portion to an int. My attempt looks like this..

    char * ReceivedStr;
    char * Mid(char * inString, int Start, int Length );


    main()
    {
    int i;
    int dis;
    char * Distance;
    ReceivedStr = "Move125";

    Distance = Mid(ReceivedStr , 4, 3);...
    See more | Go to post

  • yfredmann
    started a topic Sinlge linked List -> Delete Using One Pointer
    in C

    Sinlge linked List -> Delete Using One Pointer

    Hi dear friends,

    This problem might be so popular to some of you, but I couldn't be able to do it myself.

    The problem: How to delete a node from a single linked list using only one pointer?

    Where the target node to be deleted has a key field, and based on a match, let us say at first a sequential search, this node has to be deleted.

    What other ways that a singly linked list can be searched...
    See more | Go to post

  • Changing the size of an array passed to a function problem!

    Hi all,

    I have the following scenario:

    Code:
    int main()
    {
       char a[] = "Hello";
       printf("Modified string: %s\n", modify_str(a));
    }
    
    char *modify_str(char *b)
    {
       /* Insert a  '+'  after every letter in the string */
       /* "Hello" becomes "H+e+l+l+o+" */
       return b;
    }
    Now my...
    See more | Go to post

  • srbakshi
    started a topic Query about strings and pointers
    in C

    Query about strings and pointers

    Hi all! I have the following code:

    Code:
    typedef struct A
    {
          char* string;
    }A;
    
    //Function prototype
    void fill_up_A(A* a);
    
    int main()
    {
          A var_A;
          fill_up_A( &var_A);
          printf("String is : %s", var_A.string);
          return 1;
    }
    
    //Function definition
    void fill_up_A(A* a)
    {
    ...
    See more | Go to post

  • JonathanS
    started a topic C++ Dynamic allocation within a loop
    in C

    C++ Dynamic allocation within a loop

    I have a program in which I am trying to create a chain of (unspecified number) nodes. I want to be able to use a loop to create a new node and then link it in. I've tried it (and I think it works) to put the new within the loop and just have the compiler allocate a new version of the variable using the same name.

    E.g.,
    Code:
     for (      )
                         Node * anode = new Node();
    This doesn't seem to be...
    See more | Go to post
Working...