Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. Calling base class memeber function in child class member function

Calling base class memeber function in child class member function

Scheduled Pinned Locked Moved ATL / WTL / STL
performance
2 Posts 2 Posters 7 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 12082627
    wrote on last edited by
    #1

    Hi eveeryone, Can someone please look at my code and teach me where i am making mistake.

    void Laptop::show()
    { Computer::show();
    cout<<"weight is="<#include
    #include
    class Computer
    {
    protected:
    int wordSize;
    int memorySize;
    int storageSize;
    int speed;
    public:
    Computer(){}
    Computer(int,int,int,int);
    void show();
    };
    class Laptop
    {
    private:
    int width;
    int height;
    int length;
    int weight;

    public:
    Laptop(){}
    Laptop(int,int,int,int,int,int,int,int);
    void show();
    };
    Computer::Computer(int wdSize, int memSize, int storSize ,int spee)
    {
    wordSize=wdSize;
    memorySize=memSize;
    storageSize=storSize;
    speed=spee;
    }
    void Computer::show()
    {
    cout<<"Word Size :"<

    L 1 Reply Last reply
    0
    • U User 12082627

      Hi eveeryone, Can someone please look at my code and teach me where i am making mistake.

      void Laptop::show()
      { Computer::show();
      cout<<"weight is="<#include
      #include
      class Computer
      {
      protected:
      int wordSize;
      int memorySize;
      int storageSize;
      int speed;
      public:
      Computer(){}
      Computer(int,int,int,int);
      void show();
      };
      class Laptop
      {
      private:
      int width;
      int height;
      int length;
      int weight;

      public:
      Laptop(){}
      Laptop(int,int,int,int,int,int,int,int);
      void show();
      };
      Computer::Computer(int wdSize, int memSize, int storSize ,int spee)
      {
      wordSize=wdSize;
      memorySize=memSize;
      storageSize=storSize;
      speed=spee;
      }
      void Computer::show()
      {
      cout<<"Word Size :"<

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Your Laptop class does not inherit Computer, so you cannot call it in that way. Your definition should be:

      class Laptop : Computer
      {
      //

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups