Exactly what I was looking for, thanks!
Dan Watt
Posts
-
C++ variable promotion during operator -
C++ variable promotion during operatorI am designing a scripting engine for use in a student project, that has similar syntax to C++ but not quite all the power. I have recently come to one small problem. When you have an operation, like a+b, there needs to be a return type from that operation. (though this does have a lot to do with my engine, it also is a question as to how C++ works, since I havn't really enountered any material on this subject - maybe I'm just not looking hard enough). Say we have: float f = 1+1.0; f gets the value 2.0 since we know we are storing to a float. But, if I am not going to store to float, but rather do something like cout << 1+1.1 << endl; (not in my code, but in C++) That gets the value of 2.1 (tested in C++), but how does the compiler know to promote to a float? Seems simple enough, but the engine is designed so that types can be added, so I want to know whats the best way to know how to promote a variable to another type during an operator (specifically, a binary operator)? I guess a better way of putting it would be "How can you determine what the resulting type will be from an operator that is done on two different types"? Will the first operand have precidence, or the second?
-
Cross dependent headersHere is what I mean abstractly: I have a project that has 3 class, each defined in its own header. Class A has a variable of class B, and class B has a variable of class C. What I need to do is pass down the "this" pointer from class A to class C, so that class C can interact with some of the memebers of A. To do this, I have to pass it through B then to C. Also, class C's header file needs to include A's, and so does B. The problem is that when I include "ClassA.h" in "ClassC.h", I get C2079 errors saying that class C is not defined, when I make an instance of class C inside class B. I realize what is going on here (correct me if I am wrong) is that MSVC gets a little confused when I have the include's tangled up like this (C includes A which includes B which includes C AND A, even though I am most definately using #ifndef) Make any sense? I have seen this error a lot in the past, usually predeclaring all involved classes before making any include directives fixes this, but this time around that isnt working. Is there a fairly simple solution to this? I am using .NET, unmannaged C++, and I also tried using precompiled headers (and no, I am not using MFC, this is a straight up console app that is later going to be turned into a lib once I am done testing everything). (maybe this is neater) ClassA.h includes ClassB.h, and class A has a variable of class B ClassB.h includes ClassA.h and ClassC.h, and class B has a variable of class C. One of the methods of class B takes a pointer to a variable of class A ClassC.h includes ClassB.h and ClassA.h, and has a method that takes a pointer to a variable of class A.
-
Boost and VC++6sp5I have compiled the boost library (specifically the regex++ portion), and have successfully used it in a test app in VC6. The problem is, that im getting no Intellisense (and I am using VisualAssist), and it is quite annoying. Its a small issue, but I am wondering what directories need to be included in VC and where I need to add those directories (I tried Tools:Options). Any suggestions?
-
Non-MFC Equivalent to CFileFind?I need the functionality of CFileFind for a project, but I can't be dependent on MFC for this project. Is there an API equivalent, or better a portable library for doing this? I know Boost has a class dir_it that will do it, but it looks like its still in beta.