I want some functions of one class in another class how can i acess that functions

Recommended Answers

All 10 Replies

pick up a c++ book for beginners and start over...

well for accessing one class function in an other the easiest method is to create the same function in the other class or do over loading
like wise
class name of that class whose function u r calling::then the function name();

well for accessing one class function in an other the easiest method is to create the same function in the other class or do over loading
like wise
class name of that class whose function u r calling::then the function name();

>well for accessing one class function in an other the easiest method is to create the same function in the other class or do over loading

i dont think thats the best advice to give... how can you access one class function from another by creating same function in another class?? where does overloading come in??

> class name of that class whose function u r calling::then the function name();

even this is not correct unless you specify its a static function, which seems like a far cry for the original post at this time

ohh sorry its overriding..

dear u can acces the sum function of any class through this way try it out..
if u want addition of 2 no. in class A and class B as well
den instead of making same function again do overidding:)

dear u can acces the sum function of any class through this way try it out..
if u want addition of 2 no. in class A and class B as well
den instead of making same function again do overidding:)

excuse me ma'am.. it seems that you are totally confused amongst the various concepts of object oriented progamming.. which is very common.. so please take my suggestion and try and re-read all these concepts again and clarify your fundas.

excuse me ma'am.. it seems that you are totally confused amongst the various concepts of object oriented progamming.. which is very common.. so please take my suggestion and try and re-read all these concepts again and clarify your fundas.

i guess u should go n clear ur concepts:)

let me try and explain, overriding is a mechanism for achieving dynamic polymorphism and has nothing to do with accessing a function of one class in another. it allows a subclass to extend the functionality of a base class function. i hope u understand that 'dear' ...

I want some functions of one class in another class how can i acess that functions

class A {
   public:
   void foo() {}
};

class B {
private:
     A var1;
public:
    void boo() {var1.foo();}
};
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.