Thread: inherit the subclass from the base class

  1. #1
    Registered User
    Join Date
    Dec 2017
    Posts
    33

    inherit the subclass from the base class

    how do i publically inherit the subclass from the base class
    Code:
    #include "stdafx.h"
    #include <iostream>
    #include <fstream>
    using namespace std;
    
    template <class game>
    
    class game
    {
    private:
    
    protected:
        int nintendo;
        int sega;
        string fun;
        bool enjoy;
    public:
    
    };
    
    int main()
    {
        ofstream gaming;
        gaming.open("games.txt");
        gaming << "nintendo 1981 mario donkeykong \n";
        gaming << "sega 1991 sonic tails \n";
        gaming << "fun young sun happy \n";
        gaming << "enjoy sweet hugs toys \n";
        gaming.close();
        cin.get();
        return 0;
    }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    25,866
    I think you need to take a step back and explain what is the underlying goal that you are trying to accomplish. Presently, it looks like you heard about inheritance and class templates, and attempted to define a class template while asking about how to derive from a base class, but you don't seem to need either!
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Dec 2017
    Posts
    33
    its for an assignment can you help how do I make it

  4. #4
    Informer -Adrian's Avatar
    Join Date
    Jan 2013
    Posts
    709
    Bro I think you need to take a step back. If it's for an assignment, the teacher won't leave you hanging like that without prior information.

    Basic inheritance looks like this:
    Code:
    class Base
    {
        /* stuff */
    };
    
    class Derived : public Base
    {
        /* stuff */
    };

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 01-24-2016, 05:02 AM
  2. Class design (inherit or not)
    By Raigne in forum Game Programming
    Replies: 4
    Last Post: 03-03-2008, 02:10 PM
  3. Friend cannot inherit from private subclass
    By MWAAAHAAA in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2006, 04:44 PM
  4. Replies: 4
    Last Post: 12-29-2002, 12:29 AM
  5. Replies: 1
    Last Post: 11-27-2001, 01:07 PM

Tags for this Thread