simple question: how to do this ?

M

mandatory

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 ?
 
K

Karl Heinz Buchegger

mandatory said:
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?
 
T

Tim Love

...
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()
{}
 
R

Rolf Magnus

mandatory said:
Another question which puzzles me:

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().
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top