I meant this:
let me explain it like this.
I have *virtual int speed()* in class A.(in file A.h)
I inherited class in class B(in file B.h) as class B:public A
class B have a private member m_speed.
Now I have to return m_speed from speed() from class B as I would
instantiate an object of class B to use it.
So if write my prgram like this:

class B:public A
{
private:
int m_speed();
}

int B::speed()
{
return m_speed;
}

would it work ?



On 13 June 2010 12:37, Rohit Saraf <rohit.kumar.sa...@gmail.com> wrote:

> Make those functions public
> And even if M_speed is public of another class, it is still it another
> class, you cannot just address it like m_speed in other classes.
> Does it help?
>
> --------------------------------------------------
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
>
> On Sun, Jun 13, 2010 at 12:31 PM, akshay khatri <akshaykhatri...@gmail.com
> > wrote:
>
>> Hi
>>
>> On 13 June 2010 12:26, Rohit Saraf <rohit.kumar.sa...@gmail.com> wrote:
>>
>>> M-speed is private and you cannot call it from outside myPlugin. (though
>>> i did not understand what u wanted to say)
>>> Can you write ur prob explicitly?
>>>
>>
>> I want to use speed() and direction() defined in myPlugin.h in
>> otherPlugin.cpp. How can I use it(syntax) ? If I try to return a variable
>> such as m_speed(even if defined in public part of class otherPlugin) , it
>> gives an error.
>>
>>
>>
>>> --------------------------------------------------
>>>  Rohit Saraf
>>> Second Year Undergraduate,
>>> Dept. of Computer Science and Engineering
>>> IIT Bombay
>>> http://www.cse.iitb.ac.in/~rohitfeb14
>>>
>>>
>>>
>>> On Sun, Jun 13, 2010 at 12:20 PM, akshay khatri <
>>> akshaykhatri...@gmail.com> wrote:
>>>
>>>> I have the following code structure
>>>> in my file myPlugin.h , i have defined this
>>>>
>>>>    virtual int speed();
>>>>
>>>> and gave a dummy implementation in myPlugin.cpp
>>>>
>>>> In another file otherPlugin.h I have included this line:
>>>>
>>>>    #include <myPlugin.h>
>>>>    private:
>>>>    int m_speed;
>>>>
>>>> also class otherPlugin inherits myPlugin (public scope)
>>>> I want to redefine speed in otherPlugin.cpp
>>>> How should I return a value fromspeed() in it ?
>>>>
>>>>  int myPlugin::speed()
>>>>    {
>>>>       return m_speed;
>>>>    }
>>>> or
>>>>    int otherPlugin::speed()
>>>>    {
>>>>      return m_speed;
>>>>    }
>>>>
>>>> or anything else ?
>>>>
>>>> The error I get is that: m_speed was not declared in this scope.
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algoge...@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
>>>> .
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algoge...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to