Link to home
Start Free TrialLog in
Avatar of brightak
brightak

asked on

member function already defined or declared

I'm trying to compile a VC++ 6 program I inherited.  I'm getting 157 instances of the above error message in my header file that defines my document MFC -- all from the implementation.  The offending code snippet is attached.  I changed the program name to protect the innocent.
// Implementation
public:
   virtual ~CMyProgDoc();
 
   // Overloaded Operators
   CMyProgDoc& operator =(CMyProgDoc& Doc);
 
   CMyProgTableView*    GetTableView();
   CMyProgExplorerView* GetExplorerView();
   CMyProgBarView*      GetBarView();
   CMyProgPieView*      GetPieView();
 
#ifdef _DEBUG
   virtual void AssertValid() const;
   virtual void Dump( CDumpContext& dc ) const;
#endif
 
// Implementation - copied from MyProg v 1
public:
   virtual ~CMyProgDoc();
 
   // Overloaded Operators
   CMyProgDoc& operator =(CMyProgDoc& Doc);
 
   CMyProgTableView*    GetTableView();
   CMyProgExplorerView* GetExplorerView();
   CMyProgBarView*      GetBarView();
   CMyProgPieView*      GetPieView();

Open in new window

Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Should be related to a duplicated header compilation, you should use some "guards" in all your header files:

someheader.h
#ifndef MYHEADERNAME_H
#define MYHEADERNAME_H

all your header code here

#endif

repeat the same for all your header files (.h)
Of course MYHEADERNAME_H should be different for every header file.
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of brightak
brightak

ASKER

I copied the code as is (which is why I didn't think of that).  Maybe I got a bad version.