473,405 Members | 2,444 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,405 software developers and data experts.

simple question: how to do this ?

Another question which puzzles me:

------------------------------------
Class A{
public:
virtual void func1(void);
virtual void func2(void);
virtual void func3(void);

};

Class B : Public A{
public:
virtual void func4(void);
};
B myclass;
----------------------------------------------

When i look at myclass, i can see all 4 memberfunctions - its superb.

But in my code for func4, in class B i want to call func1() - but >inside<
the class it doesnt seem to be visible ?

ex:

void B::func4 (void)
{
func1();
}

This doesnt work, it apparently doesnt know its derived func1() - how should
i solve this problem ?
Jul 23 '05 #1
3 940
mandatory wrote:

Another question which puzzles me:

------------------------------------
Class A{
public:
virtual void func1(void);
virtual void func2(void);
virtual void func3(void);

};

Class B : Public A{
public:
virtual void func4(void);
};

B myclass;
----------------------------------------------

When i look at myclass, i can see all 4 memberfunctions - its superb.

But in my code for func4, in class B i want to call func1() - but >inside<
the class it doesnt seem to be visible ?

ex:

void B::func4 (void)
{
func1();
}

This doesnt work, it apparently doesnt know its derived func1() - how should
i solve this problem ?


There is no problem.
Everything should work as you expect it to be.
So the problem you face must be something else.
Can you provide a complete example and the error message
you get from your compiler?

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 23 '05 #2
"mandatory" <ok*****@nptklooohs.ru> writes:

...
This doesnt work, it apparently doesnt know its derived func1() - how should
i solve this problem ?

You haven't said what led you to believe that it doesn't know. The code
you posted doesn't have any code for func1,func2,func3 which is maybe
what's confusing you (and us - sending code fragments isn't a good idea).
Try the following - it compiles/run for me.

class A{
public:
virtual void func1(void){};
virtual void func2(void){};
virtual void func3(void){};

};

class B : public A{
public:
virtual void func4(void);
};
B myclass;

void B::func4 (void)
{
func1();
}

int main()
{}

Jul 23 '05 #3
mandatory wrote:
Another question which puzzles me:

------------------------------------
Class A{
class A{
public:
virtual void func1(void);
virtual void func2(void);
virtual void func3(void);

};

Class B : Public A{
class B : public A{
public:
virtual void func4(void);
};
B myclass;
----------------------------------------------

When i look at myclass, i can see all 4 memberfunctions - its superb.

But in my code for func4, in class B i want to call func1() - but >inside<
the class it doesnt seem to be visible ?
func1 is only declared. There is no implementation for it.
ex:

void B::func4 (void)
{
func1();
}

This doesnt work, it apparently doesnt know its derived func1() - how
should i solve this problem ?


Implement func1().

Jul 23 '05 #4

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

Similar topics

2
by: Trimbitas Sorin | last post by:
Hello I have a simple syntax question : What does the following line mean: 1: %checkType; ?? I know that @test="" is an array and $test="" is a simple variable. Thank you With best regards...
1
by: Proteus | last post by:
Any help appreciated on a small perl project I need to write for educator/teaching purposes. I have not programmed perl for some time, need to get up to speed, maybe some kind souls hrere will help...
2
by: Raskolnikow | last post by:
Hi! I have a very simple problem with itoa() or the localtime(...). Sorry, if it is too simple, I don't have a proper example. Please have a look at the comments. struct tm *systime; time_t...
7
by: abcd | last post by:
I am trying to set up client machine and investigatging which .net components are missing to run aspx page. I have a simple aspx page which just has "hello world" printed.... When I request...
2
by: Allain Bøge | last post by:
It is really a simple question. Visual Basic .NET (2003) I create 2 forms (Form1 and Form2) I create a checkbox in Form1 (checkbox1) I create a checkbox in Form2 (checkbox1) I go to Form1...
4
by: dba_222 | last post by:
Dear Experts, Ok, I hate to ask such a seemingly dumb question, but I've already spent far too much time on this. More that I would care to admit. In Sql server, how do I simply change a...
14
by: Giancarlo Berenz | last post by:
Hi: Recently i write this code: class Simple { private: int value; public: int GiveMeARandom(void);
30
by: galiorenye | last post by:
Hi, Given this code: A** ppA = new A*; A *pA = NULL; for(int i = 0; i < 10; ++i) { pA = ppA; //do something with pA
17
by: Chris M. Thomasson | last post by:
I use the following technique in all of my C++ projects; here is the example code with error checking omitted for brevity: _________________________________________________________________ /*...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.