|
Its not very clear what you mean, maybe you can give an example of what you are trying to do?
|
|
|
|
|
eg:
base class :
class Employee
{
}
derived class 1:
class Temp:public Employee
{
}
derived class 2:
class Perm:public Employee
{
}
main:
#include "Perm.h"
#include "Temp.h" <- this is where the redefinition occur due to 2 copy of "Employee.h"
void main (void)
{
Temp a;
Perm b;
......
}
so beside changing the structure any solution to solve this prob ??
thanx a lot !!
bk
|
|
|
|
|
You need to protect the header file from multiple inclusions.
A portable way is to do something like this:
#ifndef __FILE_H__
#define __FILE_H__
#endif // __FILE_H__
If you are not worried about portability and is using VS.NET, you can write something like this:
#pragma once
--
Shine, enlighten me - shine
Shine, awaken me - shine
Shine for all your suffering - shine
|
|
|
|
|
|
It automatically protects header files. A VS.NET extension which IMHO should be incorporated into C/C++. Idiot proof protection!
--
Shine, enlighten me - shine
Shine, awaken me - shine
Shine for all your suffering - shine
|
|
|
|
|
me leaving the class room looking down my shoes.
[edit]#pragma once is not a VS.NET extension.[/edit]
|
|
|
|
|
.S.Rod. wrote:
[edit]#pragma once is not a VS.NET extension.[/edit]
Did it appear earlier? I assumed it was first included in VS.NET because VS.NET was the first environment where I noticed that the wizards generate code containing #pragma once.
Speaking of extensions, do you know by any chance if you can force folding points in C++ source files using some [un]documented trick? #region is what I want, but that seems to be a C# only feature.
--
Shine, enlighten me - shine
Shine, awaken me - shine
Shine for all your suffering - shine
|
|
|
|
|
Jörgen Sigvardsson wrote:
Did it appear earlier? I assumed it was first included in VS.NET because VS.NET was the first environment where I noticed that the wizards generate code containing #pragma once.
As far as I can tell it was already available with MSDEV 97.
Jörgen Sigvardsson wrote:
Speaking of extensions, do you know by any chance if you can force folding points in C++ source files using some [un]documented trick? #region is what I want, but that seems to be a C# only feature.
There is no way to force outlining. But the context menu shows a way to play with outlines regardless of the language you are using (they are saved in the .suo file, like bookmarks and other stuff). More info here[^].
|
|
|
|
|
.S.Rod. wrote:
But the context menu shows a way to play with outlines regardless of the language you are using (they are saved in the .suo file, like bookmarks and other stuff).
Yeah, I knew about that one. However, the .suo file is nothing I want to keep in CVS. The main reason I wanted to add the regions was to promote readability (hiding all the private stuff as much as possible which is of no interest anyway for the user of the class) and have it inlined in the code. Oh well, I guess I can't have everything.
--
Shine, enlighten me - shine
Shine, awaken me - shine
Shine for all your suffering - shine
|
|
|
|
|
It's not really a VS.NET extension coz i've used #pragma once in VC++ 6 also. Though not sure if it was present in earlier versions too or not.
And you will know my name is the Lord when I lay my vengeance upon thee.
|
|
|
|
|
Hi ,
Really thanx a lot for the help !!!
bk
|
|
|
|
|
Oh yeah, i forgot to mention that the define at the top of each header file should be unique for each header file.
I usually use this pattern:
If the file is called file.h, the define symbol becomes __FILE_H__
So, if I had Employee.h, I'd define the symbol as __EMPLOYEE_H__
--
Shine, enlighten me - shine
Shine, awaken me - shine
Shine for all your suffering - shine
|
|
|
|
|
check their copy of windows.h and let me know if it has these lines maybe 20 lines from the start?
#if(WINVER >= 0x0500)
#pragma message ("")
#pragma message ("NOTE: WINVER has been defined as 0x0500 or greater which enables")
#pragma message ("Windows NT 5.0 and Windows 98 features. When these headers were released,")
#pragma message ("Windows NT 5.0 beta 1 and Windows 98 beta 2.1 were the current versions.")
#pragma message ("")
#pragma message ("For this release when WINVER is defined as 0x0500 or greater, you can only")
#pragma message ("build beta or test applications. To build a retail application,")
#pragma message ("set WINVER to 0x0400 or visit http://www.microsoft.com/msdn/sdk")
#pragma message ("to see if retail Windows NT 5.0 or Windows 98 headers are available.")
#pragma message ("")
#pragma message ("See the SDK release notes for more information.")
#pragma message ("")
#endif
I found them lurking in my copy of windows.h but when I went to the PSDK site at Microsoft to update it tells me I already have the latest version installed.
Rob Manderson
http://www.mindprobes.net
|
|
|
|
|
That shows you how OLD VC 6 is. "Windows NT 5.0" is what we now call Win 2000. You should be using the PlatSDK include & lib dirs instead of the ones that shipped with VC, so you'll never see that message. Assuming you have a recent PSDK, you can click on Visual Studio Registation->Register PSDK Directories with Visual Studio in the PSDK program group to put the dirs in VC's search path.
--Mike--
THERE IS NO THERE IS NO BUT THERE IS
MAGIC PIXIE DUST BUSINESS GENIE CODE PROJECT
Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
Aha!!!! Now I know why some constants weren't defined! I've installed the platform SDK within the last three months (when I arrived in the US and put my new machine together) but I never thought to update the search paths in Visual Studio... Doh!!!
Thanks Mike
Rob Manderson
http://www.mindprobes.net
|
|
|
|
|
hello I need help ,I want to disable key 'print screen' and 'Ctrl+C' and 'Ctrl+V' in MFC(use CRichEditCtrl) but I don't know how to do,Please help
thank you.
i am a student in thailand
|
|
|
|
|
I need a class of some sort that takes an equation like 12391+19-334+x^2=d^4*123 or somthing and it must find when the values of x and d or more values multiple values are correct but it must accept a string type? As in the equation will be located within a string. DDoes anyone know where I can find a program that does this? Exactly?
|
|
|
|
|
Mathcad? Maple?
--
Shine, enlighten me - shine
Shine, awaken me - shine
Shine for all your suffering - shine
|
|
|
|
|
Hi,
is it safe to call KillTimer() inside a TimerProc? MSDN does not mention it's bad for a timer proc to stop it's timer, just want to make sure I'm not doing something evil...
Thanks, Moak
|
|
|
|
|
|
thanks ![Smile | :)](https://codeproject.freetls.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
Is it possible to have SHFileOperation automatically create new folders when copying files? For instance: "d:\testfile.txt" to "d:\somefolderthatdoesn'tcurrentlyexist\testfile.txt". If it doesn't do that, is there an easy way to get around that limitation, without having to do some complex string parsing to find and make new folders?
|
|
|
|
|
I'll be posting my FileSystem article soon. It provides this and other convenient functions. Meanwhile, here's the logic:
long FileSystem::createDir
(CString strDirectory)
{
if (dirExists (strDirectory))
return (Status::Duplicate);
CString strDirParent;
getParentDir (strDirectory, strDirParent);
if (!strDirParent.IsEmpty() && !dirExists (strDirParent))
{
long nStatus = createDir (strDirParent);
if (nStatus == FileSystem::Status::Error)
return (nStatus);
}
DWORD dwStatus = ::CreateDirectory (strDirectory, NULL);
if (dwStatus == 0)
return (Status::Error);
return (Status::Success);
} /ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Anyone know how to create those bubble-style tool tips? standard tool tips derived from CToolTipCtrl are such a boaring rectangle.
|
|
|
|
|
Mel wrote:
Anyone know how to create those bubble-style tool tips? standard tool tips derived from CToolTipCtrl are such a boaring rectangle.
Have you looked here on CP?
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|