im trying to do something here but that error shows up i really have no idea how to get it done right i tried to put all the variables in the Figure.h as GLfloat instead of just float and the same error keeps appearing any idea?
here is my Figure.h
Class Figure
{
public:
Figure(float x,float y,float z);
void Paramete...
Hi,all:
this is quoted from Effective C++ 3rd editiion
const_cast is typically used to cast away the constness of objects. It is the only C++-style cast that can do this.
My question is can const_cast add constness to a non-const object?
Actually i wrote a small programme trying to approve my thought.
class ConstTest
{
public:...
Possible Duplicate:
C++ convert int and string to char*
Hello, i am making a game and I have a score board in it. The score is stored in an int variable but the library im using for the game needs an array of chars for its text outputting for my scoreboard.
So how do i turn an int into an array of chars?
int score = 1234; ...
I have a base abstract class MyClass, and it has an interface IMyClass. I have 2 other classes (MyClassA, and MyClassB) that inherit from MyClass and include the IMyClass Interface.
I have a fourth class (MyList) that inherits from List<IMyClass> and it has an interface that has a method
Add(IMyClass value);
All classes have been ...
Possible Duplicate:
Direct casting vs 'as' operator?
Can someone explain the difference to me and which one is better to use? I know in some situations I can only use one or the other.
(int)value
value as int
...
A static check tool shows a violation on the below code:
class CSplitFrame : public CFrameWnd
...
class CVsApp : public CWinApp
CWnd* CVsApp::GetSheetView(LPCSTR WindowText)
{
CWnd* pWnd = reinterpret_cast<CSplitFrame*>(m_pMainWnd)->m_OutputBar.GetChildWnd(WindowText);
return pWnd;
}
ERROR MSG:
Clas...
I was wondering:
If I have structure definitions, for example, like this:
struct Base {
int foo;
};
struct Derived {
int foo; // int foo is common for both definitions
char *bar;
};
can I do something like this?
void foobar(void *ptr) {
((struct Base *)ptr)->foo = 1;
}
struct Derived s;
foobar(&s);
e. g. cast the void p...
In C, it's not an error to cast pointers to and from void *.
A major obstacle in porting to C++ is the need to cast pointers when returning from functions dealing with generic pointers such as malloc, and functions declared in my own code such as void *block_get(Blkno const blkno);.
My code however is intended to be compiled by C and C...
I wish to take an integer as a command line argument, but if the user passes a non-integer string, this will cause a stack overflow. What is the standard way to ensure atoi() will be successful?
...
I am trying to convert a date to datetime but am getting errors. The datatype I'm converting from is (float,null) and I'd like to convert it to DATETIME.
The first line of this code works fine, but I get this error on the second line:
Arithmetic overflow error converting expression to data type datetime.
CAST(CAST( rnwl_efctv_dt AS I...
Hi,
I wish to compare index of an element in a std::vector to an unsigned value. If I directly compare like;
if(std::distance(...)>min_distance) // true for some
I just get a warning, but works fine. However, to get rid of the warning, if I cast min_distance to int, I do not get any comparison result (although there is)
if(std::dista...
Given a time:
1286294501433
Which represents milliseconds passed since 1970, how do we convert this to a DateTime data type? EG:
transactionTime = "1286294501433";
UInt64 intTransTime = UInt64.Parse(transactionTime);
DateTime transactionActualDate = DateTime.Parse(intTransTime.ToString());
Throws:
String was not recognized ...
I am working on C firmware project. I have a union that is defined as,
typedef union {
unsigned long value;
unsigned char bytes[4];
} LONGVALUE;
I also have a function that has this prototype,
char sendHexToASCII_UART(char *msg, int cnt);
and a variable of type LONGVALUE defined as,
LONGVALUE countAddr;
THE PROBLEM:
I f...
I have following xml file:
<doc_xml>
<nodes>
<node id='1' spec="{spec_a=0.9, spec_b=0.1}" />
<node id='2' spec="{spec_a=0.1, spec_b=0.3}" />
<node id='3' spec="{}" />
</nodes>
</doc_xml>
This code was created using Groovy MarkupBuilder.
Now I would like to parse this file in a groovy script:
def xml = new XmlParser().parseText...
I'm trying to do some unit testing on a project that unfortunately has high level of unit interdependence. Currently, a lot of our classes look to a custom UserIdentity object to determine authentication, but that object has a lot of internal hoop-jumping that I would just as soon avoid when trying to test individual unit functionality...
I have read other related posts, but am still not quite sure how, or if it is possible to Dynamically cast (Interface to Implementation) in Java. I am under the impression that I must use Reflection to do so.
The particular project I am working on requires a usage of many instanceof checks, and it is, in my opinion getting a bit out o...
Say I have a class named Base and a class that derives from it called SuperBase. Given that add takes in a Base*, would either of these be valid:
SuperBase *super = new SuperBase;
bases.add(super);
Or
SuperBase *super = new SuperBase;
bases.add((Base*)super);
...
I have a custom class CurvePoint which I define a set of data items to draw on the screen using DrawCurve
I written a cast routine to convert CurvePoint to Point, but I am getting the error
At least one element in the source array could not be cast down to the destination array type. when I try to use the .ToArray method in an Arrayli...
I am using my custom CSVDataReader : IDataReader {} to insert Bulk values in a Database table.
Every datatype but the Bit (from "1"/"0") is parsed perfectly. I am getting the following error
" value of type String from the data source cannot be converted to type bit" while parsing 0 or 1 as bool
If I change these values to "true"/"fal...
This code was written in Visual Studio 2003, but now I compile it in 2008.
int AFXAPI AfxMessageBox(LPCTSTR lpszText, UINT nType = MB_OK, UINT nIDHelp = 0);
if(iiRecd == SOCKET_ERROR || iiRecd == 0) {
iErr = ::GetLastError();
AfxMessageBox(CString(iErr));
goto PreReturnCleanup;
}
In 2003, it works fine, but in 2008, it shows me...