Results 1 to 4 of 4

Thread: Why doesn't this work (inheritance & namespaces)

Threaded View

  1. #1

    Thread Starter
    Fanatic Member twanvl's Avatar
    Join Date
    Dec 2001
    Posts
    771

    Why doesn't this work (inheritance & namespaces)

    This code gives an error ("illegal member initialization: 'ifstream' is not a base or member")
    Code:
    #include <fstream>
    
    namespace MyNamespace{
        class MyClass;
    }
    
    class MyNamespace::MyClass : public std::ifstream{
    public:
        MyClass() : std::ifstream() {}
    };
    but this code does not:
    Code:
    #include <fstream>
    using std::ifsream;
    
    namespace MyNamespace{
        class MyClass;
    }
    
    class MyNamespace::MyClass : public ifstream{
    public:
        MyClass() : ifstream() {}
    };
    What am I doing wrong?

    EDIT: I'm using MSVC 6
    Last edited by twanvl; Mar 16th, 2002 at 07:44 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width