|
-
Mar 15th, 2002, 12:41 PM
#1
Thread Starter
Fanatic Member
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.
-
Mar 16th, 2002, 05:26 PM
#2
Monday Morning Lunatic
Code:
using std::ifsream;
Is this a typo, or exactly what was in your source file?
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Mar 17th, 2002, 07:26 AM
#3
Thread Starter
Fanatic Member
The original code did say
Code:
using std::ifstream;
I made a typo on this forum.
-
Mar 17th, 2002, 11:10 AM
#4
MSVC6 behaves very strange sometimes.
If you don't want to use a specific constructor of ifstream you can use the first method because you don't need to put ifstream into your constructor list.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|