473,383 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Application's pointer

Hi guys !

I try to work with application's pointers in c++ , and .. I have some
problems !

I have base class that contain definition of pointer to application.
This application's pointer assigned as argument to another application
that exist in this class.
The definition of the base class look like this:

class Base{

//DB
protected:
typedef int (CTMonitorBase::*pFoo) ();

//api
protected:
void Run(pFoo _apFoo);

};
This base class derived to another class. This class contain
application which suitable to the definition of the application's
pointers.
The definition of the class look like this:

class Inheritor : public Base{

int y1;
int z1;

public:
bool UserFunc(); //another new application.
int zoo(); //suitable to the definition of pFoo pointer.

};
When i try to invoke from UserFunc application to Run application with
the pointer of zoo application

bool Inheritor::UserFunc()
{
Run(zoo);
}

I got the following error:

error C2664: 'void __thiscall Base::Run(int (__thiscall Base::*)(void)'
: cannot convert parameter 1 from
'int (void)' to 'int (__thiscall Base::*)(void)'
None of the functions with this name in scope match the target
type
As i understand the problem is, the Run application can't get the
application's pointer of the Inheritor class, without
casting.

Now, I cast the pointer like this:

bool Inheritor::UserFunc()
{
Run(static_cast<pFoo>zoo);
}
But....

When i try to access in the zoo application to the Inheritor database
(like y1,z1), i read and set to wrong address in the memory.
It seems that the Inheritor class lost its database pointer in the zoo
application.

Any ideas or notes are welcome !

Aug 2 '06 #1
2 1857
da*******@walla.co.il wrote:
I try to work with application's pointers in c++ , and .. I have some
problems !

I have base class that contain definition of pointer to application.
This application's pointer assigned as argument to another application
that exist in this class.
The definition of the base class look like this:

class Base{

//DB
protected:
typedef int (CTMonitorBase::*pFoo) ();

//api
protected:
void Run(pFoo _apFoo);

};
This base class derived to another class. This class contain
application which suitable to the definition of the application's
pointers.
The definition of the class look like this:

class Inheritor : public Base{

int y1;
int z1;

public:
bool UserFunc(); //another new application.
int zoo(); //suitable to the definition of pFoo pointer.

};
When i try to invoke from UserFunc application to Run application with
the pointer of zoo application

bool Inheritor::UserFunc()
{
Run(zoo);
}

I got the following error:

error C2664: 'void __thiscall Base::Run(int (__thiscall Base::*)(void)'
: cannot convert parameter 1 from
'int (void)' to 'int (__thiscall Base::*)(void)'
None of the functions with this name in scope match the target
type
As i understand the problem is, the Run application can't get the
application's pointer of the Inheritor class, without
casting.

Now, I cast the pointer like this:

bool Inheritor::UserFunc()
{
Run(static_cast<pFoo>zoo);
}
But....

When i try to access in the zoo application to the Inheritor database
(like y1,z1), i read and set to wrong address in the memory.
It seems that the Inheritor class lost its database pointer in the zoo
application.

Any ideas or notes are welcome !
Your message is too confusing. Show us a complete but minimal sample
that demonstrates the problem (i.e., one that we can copy and paste
unchanged to get the same error). See this FAQ on posting code:

http://parashift.com/c++-faq-lite/ho...t.html#faq-5.8

Cheers! --M

Aug 2 '06 #2
da*******@walla.co.il wrote:
Hi guys !

I try to work with application's pointers in c++ , and .. I have some
problems !
After reading your message, I think everywhere you used "application", I
think you mean "function". Your message becomes much more clear then.
class Base{

//DB
protected:
typedef int (CTMonitorBase::*pFoo) ();

//api
protected:
void Run(pFoo _apFoo);

};
class Inheritor : public Base{

int y1;
int z1;

public:
bool UserFunc(); //another new application.
int zoo(); //suitable to the definition of pFoo pointer.

};
When i try to invoke from UserFunc application to Run application with
the pointer of zoo application

bool Inheritor::UserFunc()
{
Run(zoo);
}

I got the following error:

error C2664: 'void __thiscall Base::Run(int (__thiscall Base::*)(void)'
: cannot convert parameter 1 from
'int (void)' to 'int (__thiscall Base::*)(void)'
None of the functions with this name in scope match the target
type
Maybe try this:

Run(&Inheritor::zoo);

but I am not sure if a pointer to member of derived (Inheritor::*) can
be converted to a pointer to member of base (Base::*).

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Aug 2 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Howie | last post by:
Hi, i want to write a application with pluginsupport, with some extras. The application is devided in several parts. 1) function classes a la <math.h> for 3d-calculation, matrix, vector,...
1
by: Arnaud Debaene | last post by:
Hello, I think I found a bug in VC 7.1 concerning destruction of stack objects when linking a static, non managed, C++ library within a managed C++ application. Here is a repro case : 1)...
1
by: zoltan | last post by:
Hello, I have a C++ MFC application which sometimes crashes exactly 1 minute after starting the app. "sometimes" means maybe after the first start, maybe after the tenth. The crash happens on...
2
by: SM | last post by:
Hello group, we are converting a VB6 application, written by other people, for .NET Framework. Original application depends on a DLL written in standard C. The application communicates with an...
8
by: CaptainDeep | last post by:
Hi all, I have couple of questions about architecting web application using asp.net 1. is ther any performance gain in using c# over vb.net 2. best way to handle transactions in .net? using ado...
8
by: Matthew Wells | last post by:
Hello, How do I tell if a variable dim'd as an Access.Application has something in it. dim mApp as Access.Application set mApp = new Access.Application mApp.OpenCurrentDatabase mydb.mdb
1
by: Stou Sandalski | last post by:
Hi, I have an application consisting of a main C++ class (and other classes) stored inside a DLL. The application uses a small main executable that links against the main DLL, then initializes...
2
by: sid | last post by:
Hi! can anyone please tell me the use (application) of pointers to functions? e.g. void *func() { _ _ __ _____ }
3
by: Firecore | last post by:
Does anyone know how to use this? I was browsing a few tutorials on the net, and I saw one that shows how to display stuff on the screen. I added a few events. This is my code: #include...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.