如何在oop(inheritane)中使用朋友资金? [英] How can use the friend fundtion in oop(inheritane)?

查看:127
本文介绍了如何在oop(inheritane)中使用朋友资金?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想访问与另一个类继承的不同类的数据,但我不知道我怎么做我尝试过如下..所以帮助我?

这里是样本我的代码..

A类{};

类B {};

类C {};

级D:公共A,公共B,公共C {

//这里我想打电话给朋友基金这么帮帮我?

};



我尝试过:



朋友无效结果(伊斯兰,Pakstudy,电脑); / /它是伊斯兰等不同类别的decler

无效结果(伊斯兰是,Pakstudy pk,计算机cm){

system(cls);

cout<<\ t \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ < endl;

cout<<\t\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\标记\t获得标记<< endl;

cout<<\ t圆形:1 \t \t 25 \t<< is.ismarks<< endl;



结果(Islammic; Pakstudy; Computer); //这里是错误,这是我想要访问数据的另一个类但是syntex错误

解决方案

你调用带参数的函数(在你的情况下是伊斯兰教,Pakstudy,电脑)。

参数用逗号(,)分隔:



结果(伊斯兰,Pakstudy,电脑);



这是否会解决你的朋友问题,我不知道没看到整个代码。



Matt

i want to access the data of different classes which are inherit with another class but i dont know how i can do i have tried as below.. so help me?
here is the sample of my code..
class A{};
class B{};
class C{};
class D:public A,public B,public C{
// here i want to call friend fundition so help me?
};

What I have tried:

friend void result(Islamic,Pakstudy,Computer);// it is decler in different classes like Islamic etc.
void result(Islamic is,Pakstudy pk,Computer cm){
system("cls");
cout<<"\t\t\t\t\t\t\t RESULT OF QUIZ COMMPETATION\t\t\n\n"<<endl;
cout<<"\t\t\t\t\t\t\t Quastion Category: Islamic Study \t\t Total marks \t Obtain Marks "<<endl;
cout<<"\t\t\t\t\t\t\t Round : 1 \t\t 25 \t "<<is.ismarks<<endl;

result(Islammic;Pakstudy;Computer); //here is error ,this an other class in i want to access data but syntex error

解决方案

You call a function with arguments (in your case Islamic, Pakstudy, Computer).
Arguments are separated by commas (,):

result(Islammic,Pakstudy,Computer);

Whether that will fix your friend problem, I don't know without seeing the entire code.

Matt


这篇关于如何在oop(inheritane)中使用朋友资金?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆