从其他命名空间创建派生类

时间:2016-11-20 12:09:00

标签: class namespaces derived

我需要为我的一个主题执行此操作。这是代码,我的问题是在PDA :: class pda_ipari:public pda_basic,我需要创建一个名称空间,该名称空间具有来自其他名称空间的派生类。你能帮帮我吗?

#include <iostream>

using namespace std;

namespace PDA{
class pda_basic{
private :
    float cpu_ghz;
    int cpu_core;
    int memory;
    int storage;
public :

    float getGhz()
    {
        return cpu_ghz;
    }

    void setGhz(float m)
    {
        cpu_ghz=m;
    }

    int getCore()
    {
        return cpu_core;
    }

    void setCore(int m)
    {
      cpu_core=m;
    }

    int getMemory()
    {
        return memory;
    }

    void setMemory(int m)
    {
      memory=m;
    }

    int getStorage()
    {
        return storage;
    }

    void setStorage(int m)
    {
      storage=m;
    }
};
}

namespace abtu9p_pda{

PDA::class pda_ipari : public pda_basic {

private:
    float display;
    string vonalkodTipus;
    int ip_vedelem;
public:
    float getDisplay()
    {
        return display;
    }

    void setDisplay(float m)
    {
      display=m;
    }
 string getVonalkod()
    {
        return vonalkodTipus;
    }

    void setVonalkod(string m)
    {
      vonalkodTipus=m;
    }
int getIP()
    {
        return ip_vedelem;
    }

    void setIP(int m)
    {
      ip_vedelem=m;
    }
};
}

int main()
{
    PDA::pda_basic tablet;

    tablet.setGhz(2.7);

    cout <<tablet.getGhz()<<endl;


    return 0;
}

0 个答案:

没有答案