Visual C++ :: Passing Class Pointer Via Socket

Oct 14, 2013

I have a function called,

App 1:
void GetImage(CImage * img) {
//Pass &img over socket to another app
}

App 2:
void DisplayImage() {
CImage * pImg = &img;
}

Is it possible to pass a class pointer as memory buffer across the socket? The above code is just an example. My question in general is, whether it's possible to pass any Classes pointer as a memory buffer across sockets.

View 7 Replies


ADVERTISEMENT

C++ :: Passing A Function Pointer As Template Argument To A Class

Aug 15, 2012

I have in the past written code for templated functions where one function argument can be either a function pointer or a Functor. Works pretty straightforward.

Now I am in a situation where I am actually trying to pass a function pointer as template argument to a class. Unfortunately this does not work, I can pass the Functor class but not the function pointer. Below code illustrates the issue:

Code:
#include <string>
#include <iostream>
#include <sstream>
#include <cstdlib>
// For demonstration
const char * external_library_call() {
return "FFFF";

[Code] .....

The idea is to have the definition of the Record class simple and readable and have a maintainable way to add auto-conversion functions to the class. So the lines I commented out are the desirable way how I want my code to look. Unfortunately I could not come up with any way that was close to readable for solving this.

View 3 Replies View Related

Visual C++ :: Passing Pointer Into ActiveX Control?

Oct 21, 2012

I'm writing an ActiveX control. In one of the functions I'd like the user to be able to pass me a pointer to a buffer that they created which I can then fill with data and return a success/error code. What's the appropriate way to do this? I was thinking about just using an OLE_HANDLE type for the parameter and then casting that to pointer inside the OCX but I'm not sure if that's safe or the right way to do it.

View 2 Replies View Related

Visual C++ :: How To Get Pointer To CMyView Class From CMainFrame Class

Nov 29, 2013

My program is a basic MFC AppWizard (exe) created project in VC++ 6. In MainFrm.cpp, I am trying to access some user defined CMyView member functions. However when I try to do the standard procedure to get the CMyView pointer in MainFrm.cpp, I get the " ... 'CMyView' : undeclared identifier" error. To resolve this, I add " #include myView.h " at the top of MainFrm.h which then produces the following errors:

Code:
myview.h(21) : error C2143: syntax error : missing ';' before '*'
myview.h(21) : error C2501: 'CMyDoc' : missing storage-class or type specifiers
myview.h(21) : error C2501: 'GetDocument' : missing storage-class or type specifiers

What do these errors mean? Is there a simple way to access CMyView member functions from CMainFrame?

View 8 Replies View Related

Visual C++ :: Pointer / Reference To Class Within Class?

Oct 3, 2012

I have encountered a problem I can't see to solve. I want to access a function and can't seem to find the right combination to get me there. Here is what I am looking at:

CFoo1::CFoo2::GetStrDataC(int nRow) const

How do I call the GetStrDataC function from another class?

View 6 Replies View Related

Visual C++ :: How To Get Pointer To CDialogBar From CView Class

Nov 22, 2013

My program (Test) is a basic MFC AppWizard (exe) created project. I have followed the steps in the link below to create a docked dialog box (myDialog) using VC++. [URL]...

The dialog box works, however, I have 2 issues that I am trying to resolve.

1) I have added a button to the Dialog box, however, when I run the application they start as disabled (note: the Disabled option on the Button Properties is unchecked). If I add function myDialog::OnButton to the myDialog class, the button remains disabled, however, if I add the function CTestView::OnButton to the View class, the button becomes active and works. How can I make the button work from the myDialog class?

2) I would like to be able to change an Edit box in the same dialog box when I click the button. How can I access the pointer to the myDialog from the View class?

View 2 Replies View Related

Visual C++ :: Friend Class And Pointer Function

Mar 9, 2013

I need understanding this block of code, particularly this line : *getLeftChild() { return this - _child; }

Code:

public class UpperNode {
BOX _box;
int _child;
FORCEINLINE UpperNode *getLeftChild() { return this - _child; }
...
};

Here I have this function:

Code:
void
UpperNode::visulization(int level) {
if (isLeaf())
_box.visulization();
else
if ((level > 0)) {

[Code] .....

It also makes calls for "getLeftChild()";

But I see that getLeftChild expects function pointer, and I absolutely have no clue where "this" comes from inside function body.

(return this - _child) - "this" has to be integer.

Or, if we gave pointer, and "this" is referring to some UpperNode, then I can't understand to which one, I have no UpperNode array defined or something. So if this functions is actually scaling pointer address, then scaling where to? I could comprehend it, if I had some array of UpperNodes, but not just class. I have UpperNodes array defined in other friendly class, but don't think they are related .....

View 2 Replies View Related

Visual C++ :: Pointer To Incomplete Class Is Not Allowed

Jun 16, 2013

Here is the pseudocode,

Code:
class myDX9Widget {
std::vector<Object*> m_vRenderObjects;
};
class Object {
};
class Lorry : public Object {
Activity *activity;

[Code] .....

Don't worry about the exact syntax here, I'd like to concentrate, on a conceptual level, why the line

lorry->Owner->m_vRenderObjects.push_back(pallet);

is not allowed

lorry is regarded as "Pointer to incomplete class"

View 4 Replies View Related

C++ :: Cast Base Class Pointer To Derived Class Pointer

Feb 6, 2015

I create an instance of a base class (not derived class) and assign it to base class pointer. Then, I convert it to a pointer to a derived class and call methods on it.

why does it work, if there is a virtual table?

when will it fail?

// TestCastWin.cpp : Defines the entry point for the console application.//

#include "stdafx.h"
#include <iostream>
class B
{
public:
B(double x, double y) : x_(x), y_(y) {}
double x() const { return x_; }

[Code] ....

View 14 Replies View Related

Visual C++ :: Bitmap Display From Buffer Received By TCP Socket

Feb 6, 2013

I want to display my image on window without saving it.

When data is received window size changes but there is no display on window.

My Code is:

Code:

int iBufferLength;
int iEnd;
int iSpaceRemaining;
int i;
iBufferLength = iSpaceRemaining = sizeof(chIncomingDataBuffer);
iEnd = 0;
iSpaceRemaining -= iEnd;

[code].....

where I'm doing wrong?

View 1 Replies View Related

C++ :: Calling Defined Function Pointer From Another Pointer To Class Object?

Aug 19, 2014

I am attempting to implement function pointers and I am having a bit of a problem.

See the code example below; what I want to be able to do is call a function pointer from another pointer.

I'll admit that I may not be explaining this 100% correct but I am trying to implement the code inside the main function below.

class MainObject;
class SecondaryObject;
class SecondaryObject {
public:

[Code]....

View 10 Replies View Related

C/C++ :: Passing A Global Pointer?

Feb 29, 2012

Let's say I've got something like this:

struct Box{
//something
};
typedef struct Box* pBox;

[Code]....

function fun recieves the address(which is NULL) and then allocates the memory for the Box; Let's say I cannot return the address of new allocated p and I can't also use that pointer p(from main) without passing it into a function.

Q: How can I make it that I could operate in function "fun" as I operate on orginal pointer p(from main), right now I'm just passing the address to my function but I can't change the 'global' pointer p ;(.

I remember in pascal it's like:
"function(var pointer:[pointer to sth])"
and all is done.

View 14 Replies View Related

C :: Passing A Pointer To Array Of Structs

Nov 20, 2013

what I am trying to do is to pass to a function the address of an array of structs, so I can later modify the items within the struct, within the array

Code:
typedef struct { //A struct of name auctionint bidder;float bid;} auction;
void myFunction (auction * auctionItem[]){(*aucItem[x]).bid = y;(*aucItem[x]).bidder = z;}
int main(){auction theItems[10];
myFunction(theItems);} Where x, y, and z can be any number.

When I try to run my code the IDE (I'm using Code::Blocks 12.11) does not give me any errors, but it does give me a warning:

warning: passing argument 3 of '<function name>' from incompatible pointer type [enabled by default]

and the note:

note: expected 'struct <struct name> **' but argument is of type 'struct <struct name> *'.Also, when I run the program, it will crash and return garbage.

View 6 Replies View Related

C :: Passing Structure Pointer To A Function

Aug 24, 2014

I am trying to wright a program that takes student grade data from a command line file, calculates a final grade, and copies the final grades to an output file. So far I have two functions, one that creates a student structure by allocating memory for it and returning its address, and one that should take that address and fill it with data from a line from the input file. My ultimate goal is to use a linked list to connect all the structs, but for now I just want to get the functions working. When I run what I have so far, I get an error C2440 (using visual 2010) that says "cannot convert from 'cStudent *', to 'cStudent', and points to the line where I call my fill function. How should structure pointers be passed?

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct student // Declaring student structure globally.

[Code] .....

Also, here is a sample of what a line from the input file would look like:
Bill Gates, 60, 54, 38, 62, 65, 60, 50

View 2 Replies View Related

C :: Passing Array Of Pointer To A Function

Sep 7, 2013

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_CMD_LINE 500
void tokenize(char *cmd_ln, char *fun_tknzd[], int *argument_cnt);

[Code] ....

I am trying to pass the value of fun_tknzd to str_tknzd

View 4 Replies View Related

C++ :: Passing Pointer Into Template Function

Oct 14, 2014

I'm trying to pass the pointer of a dynamic array into a template function, but it keeps telling me there is no matching function to call because the parameters I'm passing in are wrong. how to make the function accept the pointer.

//main
int main()
{
srand(unsigned(time(NULL)));
int size;
int *list;
int *listCopy;

[code].....

View 4 Replies View Related

C++ :: Passing Array As Pointer To A Function?

Apr 24, 2014

I can clearly understand how to pass a dynamic array to a function and modified within the function..

My aim is to get back the array initialized as I am trying on the next sample of code..

Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <fstream>
using namespace std;
#define N3//number of bodies
void initialise( double *M[], double *X[], double *y[])

[code]....

View 14 Replies View Related

C++ :: Passing Object By Pointer To Function?

May 20, 2014

I have a Qt classes as follow:

Code:

class Vehicle {
public:
void AddData(QString str, Data* data) {
_myDataMap.insert(str,data);
} virtual void Init();

[code].....

My questions are:

After the main function called d1->Modify; the data stored in _myDataMap will get modified too.

What is the more appropriate way of passing the Data through AddData in such case?

If i do AddData(const Data & data), i will not be able to use inheritance of Data, i.e passing a subclass of Data to AddData.

View 3 Replies View Related

C++ :: Passing Vector Of Class To Function Of Another Class?

Dec 14, 2014

im passing a vector of a class to a function of another class. But i cant access the data on the classes inside the vector.

Something like that:

class CDummy{
...
public:
string m_name;

[Code].....

Im creating the vector on main() and using push_back with a pointer to an initialized CDummy instance

View 5 Replies View Related

C++ :: Passing Class As Type In Template Class

Nov 30, 2013

I am trying to pass a class as a type to a template class. This class's constructor needs an argument but I cannot find the correct syntax. Is it possible?

Here is an example of what I described above. I did not compiled it, it is for illustrative purpose only. And of course argument val of the myData constructor would be doing something more useful than simply initializing an int....

template <class T>
class templateClass {
templateClass() {};

[Code]....

My real code would only compile is I add the myData constructor:

myData () {};

and gdb confirmed that it is this constructor that get called, even with dummy(4).

View 4 Replies View Related

C++ :: Labels As Pointer - Passing Address To A Function

Mar 7, 2014

Is there such thing as passing a winforms label by reference? For example, can I create a pointer label and pass the address to a function? I've looked online but couldn't find anything. Perhaps that's a sign?

View 1 Replies View Related

C++ :: Passing Pointer To A Function - Calling Routine

Dec 4, 2013

I have this code:

#include "stdafx.h"
#include <iostream>
using namespace std;
void square_cube(float *x,float *y) {

[Code] .....

The function should pass the square of the first input parameter and the cube of the second input parameter back to the calling routine. I thought I could use a recursion but its not going to work.

View 8 Replies View Related

C :: Passing Argument 1 Makes Pointer From Integer Without A Cast

Mar 6, 2015

Code:
#include<stdio.h>
print_int_ptr(int *a){

printf(" a %i
" ,a);
printf(" &a %i
" ,&a);

[Code] .....

I get that warning : passing arg 1 of `print_int_ptr' makes pointer from integer without a cast|

View 3 Replies View Related

C :: Passing Arg 1 Of Strcmp Makes Pointer From Integer Without Cast

Jan 18, 2015

Code:

#include <stdio.h>
int main(){
int a=15 ;
int b =20 ;
strcmp((a, "20") == 0) {
printf("Correct!");

[Code] .....

passing arg 1 of `strcmp' makes pointer from integer without a cast

View 11 Replies View Related

C :: Passing Argument 1 Makes Integer From Pointer Without A Cast

Mar 26, 2014

I am having some errors with pointers and passing arguments.

Code:

#include <stdlib.h>
#include <stdio.h>
#define MAX_FILE_LENGTH 20
typedef struct node_{
int value;
struct node_* next;

[Code]....

View 3 Replies View Related

C :: How To Stop Passing Char Array Index As Pointer

Dec 23, 2013

I am trying to write a light weight printf style function.

I have got this far:

Code:

void println(const char *txData){
LOG(__PRETTY_FUNCTION__);
UARTPuts (LPC_UART0, txData);
}
void miniPrint(const char *format, ...)
{
unsigned int index = 0;
va_list argptr;
va_start(argptr, format);

[Code]....

I understand why I think. When I am passing the reference to the array possion it is outputting everything up to the next /0. So my question is how do I stop it?

I dont have much choice as to how the output wants it:

Code: void UARTPuts(LPC_UART_TypeDef *UARTx, const void *str)

Thats library code, so I dont want to change it. I.e I have to pass an address into println.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved